$headers]); $response = $client->request($method, $url, ['form_params'=>$data]); $code = $response->getStatusCode(); // Log::info("状态码:".$code); if ($code != 200) throw new \Exception("请求第三方失败"); $res = $response->getBody()->getContents(); // Log::info($res); return $response; } public function makeQrcode($url, $path=null) { if (empty($path)) { $path = storage_path('qrcode/'.time().uniqid().'_qrcode.png'); } QrCode::size(300)->format("png")->generate($url, $path); if (file_exists($path)) { $pic = UploadService::uploadFile($path); @unlink($path); return $pic; } return null; } public function hidePhone($mobile) { $res = ""; if (preg_match("/1\d{10}/", $mobile)) { $res = substr_replace($mobile, "****", 3,4); } return $res; } /** * 季度 * @param $month * @return int */ public function getQuarter($month){ if ($month == 1 || $month == 2 || $month == 3) { $quarter = 1; //第一季度 } elseif ($month == 4 || $month == 5 || $month == 6) { $quarter = 2; //第二季度 } elseif ($month == 7 || $month == 8 || $month == 9) { $quarter = 3; //第三季度 } else { $quarter = 4; //第四季度 } return $quarter; } public function getShortUrl($url){ $url = base64_encode($url); $original_url = "http://love.ufutx.net/api/admin/messageUrlGoto?uri=$url"; $link = UrlLink::firstOrCreate(['url'=>$original_url]); $code = $this->decb64($link->id); $short_url = 'ufutx.cn/s/'.$code; $link->update(['short_url'=>$short_url]); return $short_url; } public function decb64($dec) { //10进制转换成64进制 if ($dec < 0) { return false; } $map = array( 0=>'0',1=>'1',2=>'2',3=>'3',4=>'4',5=>'5',6=>'6',7=>'7',8=>'8',9=>'9', 10=>'A',11=>'B',12=>'C',13=>'D',14=>'E',15=>'F',16=>'G',17=>'H',18=>'I',19=>'J', 20=>'K',21=>'L',22=>'M',23=>'N',24=>'O',25=>'P',26=>'Q',27=>'R',28=>'S',29=>'T', 30=>'U',31=>'V',32=>'W',33=>'X',34=>'Y',35=>'Z',36=>'a',37=>'b',38=>'c',39=>'d', 40=>'e',41=>'f',42=>'g',43=>'h',44=>'i',45=>'j',46=>'k',47=>'l',48=>'m',49=>'n', 50=>'o',51=>'p',52=>'q',53=>'r',54=>'s',55=>'t',56=>'u',57=>'v',58=>'w',59=>'x', 60=>'y',61=>'z',62=>'_',63=>'=', ); $b64 = ''; do { $b64 = $map[($dec % 64)] . $b64; $dec /= 64; } while ($dec >= 1); return $b64; } public function diffDays($date1, $date2) { $datetime1 = new DateTime($date1); $datetime2 = new DateTime($date2); // 计算日期差 $interval = $datetime1->diff($datetime2); // 获取天数差 $days = $interval->days; return $days; } }