Commit 17dfde88 authored by zhoujun's avatar zhoujun

Merge branch 'test'

parents 7631dbec 4573e02b
Pipeline #1600 passed with stage
in 0 seconds
<?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(300)->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
* @var array
*/
protected $commands = [
//
'App\Console\Commands\UploadOOSImg',
];
/**
......@@ -24,8 +24,7 @@ class Kernel extends ConsoleKernel
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')
// ->hourly();
$schedule->command('UploadOOSImg')->everyMinute()->withoutOverlapping(5);
}
/**
......
......@@ -95,7 +95,7 @@ class AdminController extends Controller
return $query->where('updated_at','<',$endTime);
})->when($status == 0, function ($query) use ($status) {
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($endTime != '') $paginateAppends['endTime'] = $endTime;
if($userName != '') $paginateAppends['user'] = $userName;
......@@ -144,6 +144,16 @@ class AdminController extends Controller
$ids = explode('#',$postData['ids']);
$status = $postData['status'];
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]);
if($result) return $this->getSuccessMsg([]);
return $this->getErrorMsg('10063', '审核失败');
......
......@@ -82,6 +82,7 @@ class CardController extends Controller
$userId = $request->session()->get("uid");
$result = $this->getVerityLogin($userId);
if($result['code'] != 200) return $this->jsonReturn($result['code'], $result['msg']);
if(Cache::has($userId.':card:bind:role')) return $this->jsonReturn(10022, '绑定角色过于频繁,请稍后再试');
$roleId = $request->input('roleId');
$serverId = $request->input('serverId');
......@@ -91,8 +92,11 @@ class CardController extends Controller
$this->getCheckRoleInfoTable($tableName);
$verity = DB::connection('wx_mysql')->table($tableName)->where('uid',$userId)->where('role_id',$roleId)->select('id')->first();
if($verity) return $this->jsonReturn(0, '角色绑定成功');
Cache::put($userId.':card:bind:role',1,30);
$insert = $this->getInsertRoleInfo($userId,$roleId,$serverId,$serverName,$tableName);
if($insert['code'] == 200) return $this->jsonReturn(0, '角色绑定成功');
Cache::forget($userId.':card:bind:role');
return $this->jsonReturn($insert['code'], $insert['msg']);
}
......@@ -277,17 +281,21 @@ class CardController extends Controller
$serverId = $request->input('serverId');
$result = $this->getVerityLogin($userId);
if($result['code'] != 200) return $this->jsonReturn($result['code'], $result['msg']);
if(Cache::has($userId.':card:upload:image')) return $this->jsonReturn(10022, '上传图片过于频繁,请稍后再试');
$postData = $request->all();
if($request->hasFile('imgFile') && $request->file('imgFile')->isValid()){
$file = $request->file('imgFile');
$upload = new UploadServer();
$result = $upload->getUpload($postData,$file);
if($result['code'] != 200) return $this->jsonReturn($result['code'], $result['msg']);
Cache::put($userId.':card:upload:image',1,30);
$tableName = 'wx_card_role_'.$serverId;
$role = DB::connection('wx_mysql')->table($tableName)->where('uid',$userId)->where('role_id',$roleId)->select('id')->first();
$img = $this->getUpdateImg($result['data'],$userId,$role->id,$serverId);
if($img) return $this->jsonReturn(0, '上传成功',['src'=>$result['data']]);
if($img) return $this->jsonReturn(0, '上传成功');
Cache::forget($userId.':card:upload:image');
return $this->jsonReturn(10060, '上传失败');
}
return $this->jsonReturn(10056, '请选择要上传的图片');
......@@ -302,9 +310,11 @@ class CardController extends Controller
{
$img = WxUserImg::where('uid',$userId)->where('role_id',$roleId)->where('server_id',$serverId)->first();
if($img){
if($img->loacl_url != '' && file_exists(public_path().'/'.$img->loacl_url)) unlink(public_path().'/'.$img->loacl_url);
$img->loacl_url = $data['url'];
$img->img_url = $data['yunUrl'];
$img->status = 0;
$img->is_upload = 0;
if($img->save()) return true;
}else{
$row = new WxUserImg();
......@@ -314,6 +324,7 @@ class CardController extends Controller
$row->loacl_url = $data['url'];
$row->img_url = $data['yunUrl'];
$row->status = 0;
$row->is_upload = 0;
$row->remark = '';
if($row->save()) return true;
}
......@@ -328,116 +339,121 @@ class CardController extends Controller
public function getCardHtml(Request $request)
{
$userId = $request->session()->get("uid");
$result = $this->getVerityLogin($userId);
if($result['code'] != 200) return $this->jsonReturn($result['code'], $result['msg']);
$roleId = $request->input('roleId');
$serverId = $request->input('serverId');
if (empty($roleId) || empty($serverId)) return $this->jsonReturn(7002, '参数错误');
if (!Schema::connection('wx_mysql')->hasTable('wx_card_role_'.$serverId)) return redirect(route('index'));
$info = DB::connection('wx_mysql')->table('wx_card_role_'.$serverId)->where('uid',$userId)->where('role_id',$roleId)->where('server_id',$serverId)->first();
if(!$info) return redirect(route('index'));
$serverName = '';
if($info->server_name != ''){
$serverName = str_replace('非硬核-','',$info->server_name);
$serverName = str_replace('硬核-','',$serverName);
$serverName = str_replace('越狱-','',$serverName);
}
if(Cache::has('card:info:'.$userId.':'.$roleId)){
$data = Cache::get('card:info:'.$userId.':'.$roleId,[]);
}else{
$result = $this->getVerityLogin($userId);
if($result['code'] != 200) return $this->jsonReturn($result['code'], $result['msg']);
if (empty($roleId) || empty($serverId)) return $this->jsonReturn(7002, '参数错误');
if (!Schema::connection('wx_mysql')->hasTable('wx_card_role_'.$serverId)) return redirect(route('index'));
$info = DB::connection('wx_mysql')->table('wx_card_role_'.$serverId)->where('uid',$userId)->where('role_id',$roleId)->where('server_id',$serverId)->first();
if(!$info) return redirect(route('index'));
$serverName = '';
if($info->server_name != ''){
$serverName = str_replace('非硬核-','',$info->server_name);
$serverName = str_replace('硬核-','',$serverName);
$serverName = str_replace('越狱-','',$serverName);
}
$user = User::where('uid',$userId)->select('uid','account')->first();
$data['userName'] = $user->account ?? '';
$data['serverName'] = $serverName;
$user = User::where('uid',$userId)->select('uid','account')->first();
$data['userName'] = $user->account ?? '';
$data['serverName'] = $serverName;
$img = WxUserImg::where('uid',$userId)->where('role_id',$info->id)->where('server_id',$info->server_id)->select('id','img_url','status')->first();
if($img){
$data['userImgStatus'] = $img->status;
$data['userImg'] = $img->img_url;
}else{
$data['userImg'] = '';
$data['userImgStatus'] = -1;
}
$img = WxUserImg::where('uid',$userId)->where('role_id',$info->id)->where('server_id',$info->server_id)->select('id','img_url','status')->first();
if($img){
$data['userImgStatus'] = $img->status;
$data['userImg'] = $img->img_url;
}else{
$data['userImg'] = '';
$data['userImgStatus'] = -1;
}
$armsScore = [];
$armsStrong = [];
$armsExciting = [];
if($info->arms_score != '') $armsScore = json_decode($info->arms_score,true);
if($info->arms_strong != '') $armsStrong = json_decode($info->arms_strong,true);
if($info->arms_exciting != '') $armsExciting = json_decode($info->arms_exciting,true);
$roleScore = '00000';
if(strlen($info->role_score) == 1) $roleScore = '0000'.(string)$info->role_score;
if(strlen($info->role_score) == 2) $roleScore = '000'.(string)$info->role_score;
if(strlen($info->role_score) == 3) $roleScore = '00'.(string)$info->role_score;
if(strlen($info->role_score) == 4) $roleScore = '0'.(string)$info->role_score;
if(strlen($info->role_score) == 5) $roleScore = (string)$info->role_score;
$jobInco = config('sign.jobInco');
$data['info'] = $info;
$data['roleScore'] = $roleScore;
$data['jobImg'] = $jobInco[$info->job] ?? '';
$honorConfig = config('sign.honor');
$data['honor'] = $honorConfig[$info->honor_level] ?? $honorConfig[0];
if($info->mercenary_score == 2){
$data['ybImg'] = 'img-B';
}elseif($info->mercenary_score == 3){
$data['ybImg'] = 'img-A';
}elseif($info->mercenary_score == 4){
$data['ybImg'] = 'img-S';
}elseif($info->mercenary_score == 5){
$data['ybImg'] = 'img-SS';
}elseif($info->mercenary_score == 6){
$data['ybImg'] = 'img-SSS';
}else{
$data['ybImg'] = 'img-C';
}
$armsScore = [];
$armsStrong = [];
$armsExciting = [];
if($info->arms_score != '') $armsScore = json_decode($info->arms_score,true);
if($info->arms_strong != '') $armsStrong = json_decode($info->arms_strong,true);
if($info->arms_exciting != '') $armsExciting = json_decode($info->arms_exciting,true);
$roleScore = '00000';
if(strlen($info->role_score) == 1) $roleScore = '0000'.(string)$info->role_score;
if(strlen($info->role_score) == 2) $roleScore = '000'.(string)$info->role_score;
if(strlen($info->role_score) == 3) $roleScore = '00'.(string)$info->role_score;
if(strlen($info->role_score) == 4) $roleScore = '0'.(string)$info->role_score;
if(strlen($info->role_score) == 5) $roleScore = (string)$info->role_score;
$jobInco = config('sign.jobInco');
$data['info'] = $info;
$data['roleScore'] = $roleScore;
$data['jobImg'] = $jobInco[$info->job] ?? '';
$honorConfig = config('sign.honor');
$data['honor'] = $honorConfig[$info->honor_level] ?? $honorConfig[0];
if($info->mercenary_score == 2){
$data['ybImg'] = 'img-B';
}elseif($info->mercenary_score == 3){
$data['ybImg'] = 'img-A';
}elseif($info->mercenary_score == 4){
$data['ybImg'] = 'img-S';
}elseif($info->mercenary_score == 5){
$data['ybImg'] = 'img-SS';
}elseif($info->mercenary_score == 6){
$data['ybImg'] = 'img-SSS';
}else{
$data['ybImg'] = 'img-C';
}
$data['rank'] = empty($info->max_rank) ? '青铜5' : $info->max_rank;
if(!empty($armsScore)){
$armsScoreNum = '00000';
if(strlen($armsScore[0]['score']) == 1) $armsScoreNum = '0000'.(string)$armsScore[0]['score'];
if(strlen($armsScore[0]['score']) == 2) $armsScoreNum = '000'.(string)$armsScore[0]['score'];
if(strlen($armsScore[0]['score']) == 3) $armsScoreNum = '00'.(string)$armsScore[0]['score'];
if(strlen($armsScore[0]['score']) == 4) $armsScoreNum = '0'.(string)$armsScore[0]['score'];
if(strlen($armsScore[0]['score']) == 5) $armsScoreNum = (string)$armsScore[0]['score'];
$data['armsScoreName'] = $armsScore[0]['name'];
$data['armsScore'] = $armsScoreNum;
}else{
$data['armsScoreName'] = '';
$data['armsScore'] = '00000';
}
$data['rank'] = empty($info->max_rank) ? '青铜5' : $info->max_rank;
if(!empty($armsScore)){
$armsScoreNum = '00000';
if(strlen($armsScore[0]['score']) == 1) $armsScoreNum = '0000'.(string)$armsScore[0]['score'];
if(strlen($armsScore[0]['score']) == 2) $armsScoreNum = '000'.(string)$armsScore[0]['score'];
if(strlen($armsScore[0]['score']) == 3) $armsScoreNum = '00'.(string)$armsScore[0]['score'];
if(strlen($armsScore[0]['score']) == 4) $armsScoreNum = '0'.(string)$armsScore[0]['score'];
if(strlen($armsScore[0]['score']) == 5) $armsScoreNum = (string)$armsScore[0]['score'];
$data['armsScoreName'] = $armsScore[0]['name'];
$data['armsScore'] = $armsScoreNum;
}else{
$data['armsScoreName'] = '';
$data['armsScore'] = '00000';
}
if(!empty($armsStrong)){
$armsStrongNum = '00';
if(strlen($armsStrong[0]['level']) == 1) $armsStrongNum = '0'.(string)$armsStrong[0]['level'];
if(strlen($armsStrong[0]['level']) == 2) $armsStrongNum = (string)$armsStrong[0]['level'];
$data['armsStrongName'] = $armsStrong[0]['name'];
$data['armsStrong'] = $armsStrongNum;
}else{
$data['armsStrongName'] = '';
$data['armsStrong'] = '00';
}
if(!empty($armsStrong)){
$armsStrongNum = '00';
if(strlen($armsStrong[0]['level']) == 1) $armsStrongNum = '0'.(string)$armsStrong[0]['level'];
if(strlen($armsStrong[0]['level']) == 2) $armsStrongNum = (string)$armsStrong[0]['level'];
$data['armsStrongName'] = $armsStrong[0]['name'];
$data['armsStrong'] = $armsStrongNum;
}else{
$data['armsStrongName'] = '';
$data['armsStrong'] = '00';
}
if(!empty($armsExciting)){
$armsExcitingNum = '00';
if(strlen($armsExciting[0]['level']) == 1) $armsExcitingNum = '0'.(string)$armsExciting[0]['level'];
if(strlen($armsExciting[0]['level']) == 2) $armsExcitingNum = (string)$armsExciting[0]['level'];
$data['armsExcitingName'] = $armsExciting[0]['name'];
$data['armsExciting'] = $armsExcitingNum;
}else{
$data['armsExcitingName'] = '';
$data['armsExciting'] = '00';
}
if(!empty($armsExciting)){
$armsExcitingNum = '00';
if(strlen($armsExciting[0]['level']) == 1) $armsExcitingNum = '0'.(string)$armsExciting[0]['level'];
if(strlen($armsExciting[0]['level']) == 2) $armsExcitingNum = (string)$armsExciting[0]['level'];
$data['armsExcitingName'] = $armsExciting[0]['name'];
$data['armsExciting'] = $armsExcitingNum;
}else{
$data['armsExcitingName'] = '';
$data['armsExciting'] = '00';
}
if($info->brave_time > 0){
$His = strtotime(date('Y-m-d')) + $info->brave_time;
if(date('H',$His) > 0){
$data['braveTime'] = date('H:i',$His);
if($info->brave_time > 0){
$His = strtotime(date('Y-m-d')) + $info->brave_time;
if(date('H',$His) > 0){
$data['braveTime'] = date('H:i',$His);
}else{
$data['braveTime'] = date('i:s',$His);
}
}else{
$data['braveTime'] = date('i:s',$His);
$data['braveTime'] = '00:00';
}
}else{
$data['braveTime'] = '00:00';
Cache::put('card:info:'.$userId.':'.$roleId,300,$data);
}
return view('card.card', $data);
}
......
......@@ -141,8 +141,8 @@ class AldGmService {
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_POST, count($submitData));
curl_setopt($curl, CURLOPT_POSTFIELDS, $submitData);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($curl, CURLOPT_TIMEOUT, 5);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
curl_close($curl);
......@@ -160,8 +160,8 @@ class AldGmService {
$url .= "?" . http_build_query($submitData);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($curl, CURLOPT_TIMEOUT, 5);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
curl_close($curl);
......
......@@ -38,7 +38,7 @@ class UploadServer
return $array;
}
$originName = $file->getClientOriginalName();
self::getCheckDir( storage_path('app'),'card');
self::getCheckDir(public_path(),'card');
$fileUrl = self::getUploadFile($file,'card','aldzn-img',$originName);
if($fileUrl['error'] != ''){
$array['code'] = 10059;
......@@ -102,7 +102,8 @@ class UploadServer
$realPath = $file->getRealPath();
if(Storage::disk('upload')->put($path.'/'.$fileName, file_get_contents($realPath))){
$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{
$imgUrl['error'] = '文件上传失败!';
}
......@@ -128,10 +129,7 @@ class UploadServer
$client = $manager->init($aliyunConfig);
$result = $client->uploadFile($object, $fileUrl);
if($result == false){
exit($client->getError());
}
if($result == false) return false;
unset($result,$manager,$client);
return config('sign.OSS_CDN').$object;
}
......
......@@ -50,7 +50,7 @@ return [
'upload' => [
'driver' => 'local',
'root' => storage_path('app'),
'root' => public_path(),
],
'public' => [
......
......@@ -67,9 +67,21 @@
@if($li->status == 1) 审核通过 @endif
@if($li->status == 2) 审核拒绝 @endif
</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> <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>
@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