Commit 81138c8a authored by liyadong's avatar liyadong

Merge branch 'test' of http://gitlab.cccwangluo.com/zhoujun/uc_card into test

parents 0300d361 8b9ba646
<?php
namespace App\Console\Commands;
use Carbon\Carbon;
use Illuminate\Console\Command;
use App\Models\WxUserImg;
use App\Services\UploadServer;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
class UploadOOSImg extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'UploadOOSImg';
/**
* The console command description.
*
* @var string
*/
protected $description = '上传云图片';
/**
* @var ActivityOrder
*/
/**
* Create a new command instance.
* @param ProductOrder $productOrder
* @param ScoreDetail $scoreDetail
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
set_time_limit(0);
$this->line('开始');
$imgs = WxUserImg::where('is_upload', 0)->where('status',1)->select('id','loacl_url','img_url','is_upload')->limit(100)->get();
foreach($imgs as $img){
if($img->loacl_url != ''){
$url = UploadServer::getUploadAliyun('aldzn-img', $img->loacl_url,public_path().'/'.$img->loacl_url);
if($url){
$img->is_upload = 1;
$img->img_url = $url;
$img->save();
if($img->loacl_url != '' && file_exists(public_path().'/'.$img->loacl_url)) unlink(public_path().'/'.$img->loacl_url);
}
}
}
$this->line('结束');
}
}
\ No newline at end of file
...@@ -13,7 +13,7 @@ class Kernel extends ConsoleKernel ...@@ -13,7 +13,7 @@ class Kernel extends ConsoleKernel
* @var array * @var array
*/ */
protected $commands = [ protected $commands = [
// 'App\Console\Commands\UploadOOSImg',
]; ];
/** /**
...@@ -24,8 +24,7 @@ class Kernel extends ConsoleKernel ...@@ -24,8 +24,7 @@ class Kernel extends ConsoleKernel
*/ */
protected function schedule(Schedule $schedule) protected function schedule(Schedule $schedule)
{ {
// $schedule->command('inspire') $schedule->command('UploadOOSImg')->everyMinute()->withoutOverlapping(5);
// ->hourly();
} }
/** /**
......
...@@ -95,7 +95,7 @@ class AdminController extends Controller ...@@ -95,7 +95,7 @@ class AdminController extends Controller
return $query->where('updated_at','<',$endTime); return $query->where('updated_at','<',$endTime);
})->when($status == 0, function ($query) use ($status) { })->when($status == 0, function ($query) use ($status) {
return $query->orderBy('status','ASC'); return $query->orderBy('status','ASC');
})->orderBy('updated_at','DESC')->select('id', 'uid', 'img_url', 'status', 'updated_at')->paginate($pageNum); })->orderBy('updated_at','DESC')->select('id', 'uid', 'loacl_url','img_url', 'status','is_upload', 'updated_at')->paginate($pageNum);
if($startTime != '') $paginateAppends['startTime'] = $startTime; if($startTime != '') $paginateAppends['startTime'] = $startTime;
if($endTime != '') $paginateAppends['endTime'] = $endTime; if($endTime != '') $paginateAppends['endTime'] = $endTime;
if($userName != '') $paginateAppends['user'] = $userName; if($userName != '') $paginateAppends['user'] = $userName;
...@@ -144,6 +144,16 @@ class AdminController extends Controller ...@@ -144,6 +144,16 @@ class AdminController extends Controller
$ids = explode('#',$postData['ids']); $ids = explode('#',$postData['ids']);
$status = $postData['status']; $status = $postData['status'];
if(!in_array($status,[1,2]) || empty($ids)) return $this->getErrorMsg('10060', '参数错误'); if(!in_array($status,[1,2]) || empty($ids)) return $this->getErrorMsg('10060', '参数错误');
// $imgs = WxUserImg::whereIn('id',$ids)->select('id','loacl_url','status')->get();
// $result = true;
// foreach($imgs as $img){
// $img->status = 1;
// if($img->save()){
// if($status == 2) unlink(storage_path('app').'/'.$img->loacl_url);
// }else{
// $result = false;
// }
// }
$result = WxUserImg::whereIn('id',$ids)->update(['status' => $status]); $result = WxUserImg::whereIn('id',$ids)->update(['status' => $status]);
if($result) return $this->getSuccessMsg([]); if($result) return $this->getSuccessMsg([]);
return $this->getErrorMsg('10063', '审核失败'); return $this->getErrorMsg('10063', '审核失败');
......
...@@ -141,8 +141,8 @@ class AldGmService { ...@@ -141,8 +141,8 @@ class AldGmService {
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_POST, count($submitData)); curl_setopt($curl, CURLOPT_POST, count($submitData));
curl_setopt($curl, CURLOPT_POSTFIELDS, $submitData); curl_setopt($curl, CURLOPT_POSTFIELDS, $submitData);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($curl, CURLOPT_TIMEOUT, 30); curl_setopt($curl, CURLOPT_TIMEOUT, 5);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl); $result = curl_exec($curl);
curl_close($curl); curl_close($curl);
...@@ -160,8 +160,8 @@ class AldGmService { ...@@ -160,8 +160,8 @@ class AldGmService {
$url .= "?" . http_build_query($submitData); $url .= "?" . http_build_query($submitData);
curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "GET"); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($curl, CURLOPT_TIMEOUT, 30); curl_setopt($curl, CURLOPT_TIMEOUT, 5);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl); $result = curl_exec($curl);
curl_close($curl); curl_close($curl);
......
...@@ -38,7 +38,7 @@ class UploadServer ...@@ -38,7 +38,7 @@ class UploadServer
return $array; return $array;
} }
$originName = $file->getClientOriginalName(); $originName = $file->getClientOriginalName();
self::getCheckDir( storage_path('app'),'card'); self::getCheckDir(public_path(),'card');
$fileUrl = self::getUploadFile($file,'card','aldzn-img',$originName); $fileUrl = self::getUploadFile($file,'card','aldzn-img',$originName);
if($fileUrl['error'] != ''){ if($fileUrl['error'] != ''){
$array['code'] = 10059; $array['code'] = 10059;
...@@ -102,7 +102,8 @@ class UploadServer ...@@ -102,7 +102,8 @@ class UploadServer
$realPath = $file->getRealPath(); $realPath = $file->getRealPath();
if(Storage::disk('upload')->put($path.'/'.$fileName, file_get_contents($realPath))){ if(Storage::disk('upload')->put($path.'/'.$fileName, file_get_contents($realPath))){
$imgUrl['url'] = $folder.'/'.date('Ym').'/'.date('d').'/'.$fileName; $imgUrl['url'] = $folder.'/'.date('Ym').'/'.date('d').'/'.$fileName;
$imgUrl['yunUrl'] = self::getUploadAliyun($bucket, $folder.'/'.date('Ym').'/'.date('d').'/'.$fileName,storage_path('app').'/'.$imgUrl['url']); $imgUrl['yunUrl'] = '';
//$imgUrl['yunUrl'] = self::getUploadAliyun($bucket, $folder.'/'.date('Ym').'/'.date('d').'/'.$fileName,storage_path('app').'/'.$imgUrl['url']);
}else{ }else{
$imgUrl['error'] = '文件上传失败!'; $imgUrl['error'] = '文件上传失败!';
} }
...@@ -128,10 +129,7 @@ class UploadServer ...@@ -128,10 +129,7 @@ class UploadServer
$client = $manager->init($aliyunConfig); $client = $manager->init($aliyunConfig);
$result = $client->uploadFile($object, $fileUrl); $result = $client->uploadFile($object, $fileUrl);
if($result == false){ if($result == false) return false;
exit($client->getError());
}
unset($result,$manager,$client); unset($result,$manager,$client);
return config('sign.OSS_CDN').$object; return config('sign.OSS_CDN').$object;
} }
......
...@@ -50,7 +50,7 @@ return [ ...@@ -50,7 +50,7 @@ return [
'upload' => [ 'upload' => [
'driver' => 'local', 'driver' => 'local',
'root' => storage_path('app'), 'root' => public_path(),
], ],
'public' => [ 'public' => [
......
...@@ -67,9 +67,21 @@ ...@@ -67,9 +67,21 @@
@if($li->status == 1) 审核通过 @endif @if($li->status == 1) 审核通过 @endif
@if($li->status == 2) 审核拒绝 @endif @if($li->status == 2) 审核拒绝 @endif
</td> </td>
<td><img src="{{ $li->img_url }}" width="50px" height="30px"></td> <td>
@if($li->status == 1 && $li->is_upload)
<img src="{{ $li->img_url }}" width="50px" height="30px">
@else
<img src="/{{ $li->loacl_url }}" width="50px" height="30px">
@endif
</td>
<td>{{ @$li->updated_at }}</td> <td>{{ @$li->updated_at }}</td>
<td> <button type="button" class="btn btn-default" onclick="return showImg('{{ $li->img_url }}');">查看</button></td> <td>
@if($li->status == 1 && $li->is_upload)
<button type="button" class="btn btn-default" onclick="return showImg('{{ $li->img_url }}');">查看</button>
@else
<button type="button" class="btn btn-default" onclick="return showImg('/{{ $li->loacl_url }}');">查看</button>
@endif
</td>
</tr> </tr>
@endforeach @endforeach
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment