From f1dc5f8920354e921ab59a64dfd470439621d75c Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Tue, 31 Dec 2019 13:34:55 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E6=8E=A8=E5=B9=BF=E5=91=98=E7=BB=A7?= =?UTF-8?q?=E6=89=BFcompany=5Fid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Base/Service/PromoteService.class.php | 2 +- Application/Home/Controller/PromoteController.class.php | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Application/Base/Service/PromoteService.class.php b/Application/Base/Service/PromoteService.class.php index d1ba9e5d1..06cf3c2f4 100644 --- a/Application/Base/Service/PromoteService.class.php +++ b/Application/Base/Service/PromoteService.class.php @@ -937,7 +937,7 @@ class PromoteService { 'parent_id' => $parent ? $parent['id'] : 0, 'parent_name' => $parent ? $parent['account'] : '官方渠道', 'admin_id' => $params['admin_id'] ?? 0, - 'company_id' => $params['company_id'] ?? 0, + 'company_id' => $params['company_id'] ?? 0, 'invite_code' => $params['invite_code'] ?? '', 'create_time' => time(), ]; diff --git a/Application/Home/Controller/PromoteController.class.php b/Application/Home/Controller/PromoteController.class.php index 6b6d5ead8..d43e3250f 100644 --- a/Application/Home/Controller/PromoteController.class.php +++ b/Application/Home/Controller/PromoteController.class.php @@ -985,6 +985,9 @@ class PromoteController extends BaseController } else { $parent = $loginPromote; } + if ($parent) { + $params['company_id'] = $parent['company_id']; + } if (C('PROMOTE_AUTO_AUDIT') == 1) { $params['status'] = 1; } From 25606949f5b4df8c5fb08ec268eef6a53544a6b8 Mon Sep 17 00:00:00 2001 From: yulingwei <2436953959@qq.com> Date: Tue, 31 Dec 2019 14:08:43 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/ConsoleController.class.php | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/Application/Admin/Controller/ConsoleController.class.php b/Application/Admin/Controller/ConsoleController.class.php index e9b103c37..69a182a70 100644 --- a/Application/Admin/Controller/ConsoleController.class.php +++ b/Application/Admin/Controller/ConsoleController.class.php @@ -104,7 +104,7 @@ class ConsoleController extends Think { public function modifyLoginCheck($start_time=0, $end_time=0) { $start_time = $start_time ? strtotime($start_time) : strtotime(date("Y-m-d")); - $end_time = $end_time ? strtotime($end_time) : $start_time + 86400; + $end_time = $end_time ? strtotime($end_time) : $start_time; $this->modifyLogin($start_time, $end_time); } @@ -118,7 +118,7 @@ class ConsoleController extends Think { $end_time = $i+86400; $result = M()->query("SELECT game_id, - FROM_UNIXTIME(login_time, '%Y-%m-%d') create_time, + UNIX_TIMESTAMP(FROM_UNIXTIME(login_time, '%Y-%m-%d')) create_time, user_id, promote_id FROM @@ -135,18 +135,24 @@ class ConsoleController extends Think { GROUP BY create_time, game_id, - user_id"); + user_id, + promote_id"); if ($result) { foreach ($result as $index => $item) { - $item['create_time'] = strtotime($item['create_time']); - if ($item['create_time']) { - $res = M("login_daily_record", "tab_")->add($item); - echo "写入{$item['create_time']} $res \n"; + if (is_null($result[$index]['promote_id'])) + { + unset($result[$index]); + } + } + $step = 500; + for ($j=0;;$j+=$step) { + $insData = array_slice($result, $j, $step); + if ($insData) { + $res = M("login_daily_record", 'tab_')->addAll($insData); + echo "写入 $res \n"; } else { - echo "写入{$item['create_time']} error \n"; + break; } - - unset($result[$index]); } } else { echo "写入{$item['create_time']} 无 \n"; From f472f5e9d325572ef18da7649dd88db4a8157920 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Mon, 6 Jan 2020 14:06:07 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E6=94=B9=E6=88=90cdn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/Model/PictureModel.class.php | 63 +++--------- Application/App/Common/function.php | 25 +---- .../Base/Service/GameSourceService.class.php | 2 +- Application/Base/Service/OssService.class.php | 33 +++---- Application/Common/Common/extend.php | 12 +-- Application/Common/Common/function.php | 20 +--- Application/Home/Model/PictureModel.class.php | 32 ++---- Application/Mobile/Common/function.php | 25 +---- Public/Home/images/FileController.class.php | 97 ++----------------- 9 files changed, 59 insertions(+), 250 deletions(-) diff --git a/Application/Admin/Model/PictureModel.class.php b/Application/Admin/Model/PictureModel.class.php index d23dcbf6c..32ffa23cd 100644 --- a/Application/Admin/Model/PictureModel.class.php +++ b/Application/Admin/Model/PictureModel.class.php @@ -14,6 +14,7 @@ use Admin\Controller\BosController; use Admin\Event\QiNiuEvent; use Think\Model; use Think\Upload; +use Base\Service\OssService; /** * 图片模型 @@ -54,8 +55,8 @@ class PictureModel extends Model{ if (!isset($value['id'])) { $value['path'] = substr($setting['rootPath'], 1) . $value['savepath'] . $value['savename']; //在模板里的url路径 if ($flag) { - $info[$key]['water'] = $value['water'] = substr($setting['waterPath'], 1) . $value['savename']; //在模板里的water路径 - } + $info[$key]['water'] = $value['water'] = substr($setting['waterPath'], 1) . $value['savename']; //在模板里的water路径 + } if ($this->create($value) && ($id = $this->add())) { $value['id'] = $id; } else { @@ -63,53 +64,21 @@ class PictureModel extends Model{ unset($info[$key]); } }else { - if ($flag) { - $savename = substr(strrchr($value['path'], '/'), 1); - $info[$key]['water'] = $data['water'] = substr($setting['waterPath'], 1) . $savename; //在模板里的water路径 - $this->where(['id'=>$value['id']])->save($data); - } - } - if (get_tool_status("oss_storage") == 1) { - $path = explode("/", $value['path']); - $to = "http://" . C("oss_storage.bucket") . "." . C("oss_storage.domain") . "/icon/" . $path[4]; - $to = str_replace('-internal', '', $to); - // $to="http://down.vlcms.com/icon/".$path[4]; - $updata['savename'] = $path[4]; - $updata['path'] = "." . $value['path']; - $oss = new OssController(); - $oss->upload_game_pak_oss($updata); - $data_url['oss_url'] = $to; - $coo = $this->where(array('id' => $value['id']))->save($data_url); - } elseif (get_tool_status("qiniu_storage") == 1) {//七牛上传 - $path = explode("/", $value['path']); - $newName = $path[4]; - $QiNiu = new QiNiuEvent(); - $value['url'] = $data_url['url'] = "http://" . $QiNiu->upQiNiuFile($newName, "." . $value['path']); - $coo = $this->where(array('id' => $value['id']))->save($data_url); - }elseif(get_tool_status("cos_storage") == 1){ - $path = explode("/", $value['path']); - $newName = $path[4]; - $cos=new Coscontroller(); - $cos_res=$cos->cosupload("." . $value['path'],"/Icon/".$newName); - if(strlen($cos_res)>10){ - $data_url['url'] = $cos_res; - $coo = $this->where(array('id' => $value['id']))->save($data_url); - }else{ - return false; + if ($flag) { + $savename = substr(strrchr($value['path'], '/'), 1); + $info[$key]['water'] = $data['water'] = substr($setting['waterPath'], 1) . $savename; //在模板里的water路径 + $this->where(['id'=>$value['id']])->save($data); } - }elseif(get_tool_status("bos_storage") == 1){ //上传到百度云 - $path = explode("/", $value['path']); - $to = "http://" . C("bos_storage.bucket") . "." . C("bos_storage.domain") . "/icon/" . $path[4]; - $to = str_replace('-internal', '', $to); - $updata['savename'] = $path[4]; - $updata['path'] = "." . $value['path']; - $oss = new BosController(); - $oss->upload_bos($updata); - $data_url['bos_url'] = $to; - $coo = $this->where(array('id' => $value['id']))->save($data_url); } - - + if (C('OSS_STATUS')) { + $path = explode('/', $value['path']); + $saveFileName = 'icon/' . $path[4]; + $localFilePath = '.' . $value['path']; + $ossService = new OssService(); + $ossService->upload($localFilePath, $saveFileName); + $dataUrl['oss_url'] = $ossService->getUrl($saveFileName); + $coo = $this->where(['id' => $value['id']])->save($dataUrl); + } } return $info; //文件上传成功 } else { diff --git a/Application/App/Common/function.php b/Application/App/Common/function.php index fe85fd19b..a90af2078 100644 --- a/Application/App/Common/function.php +++ b/Application/App/Common/function.php @@ -155,34 +155,15 @@ function get_img_url($cover_id){ return ""; } $picture = M('Picture')->where(array('status'=>1))->getById($cover_id); - if (get_tool_status("oss_storage") == 1) { + if (C('OSS_STATUS')) { if(!empty($picture['oss_url'])){ return $picture['oss_url']; }else{ return 'http://' . $_SERVER['HTTP_HOST'] . __ROOT__.$picture['path']; } - }elseif(get_tool_status("qiniu_storage") == 1){ - if(!empty($picture['url'])){ - return $picture['url']; - }else{ - return 'http://' . $_SERVER['HTTP_HOST'] . __ROOT__.$picture['path']; - } - }elseif(get_tool_status("cos_storage") == 1){ - if(!empty($picture['url'])){ - return $picture['url']; - }else{ - return 'http://' . $_SERVER['HTTP_HOST'] . __ROOT__.$picture['path']; - } - - }elseif(get_tool_status("bos_storage") == 1){ - if(!empty($picture['bos_url'])){ - return $picture['bos_url']; - }else{ - return 'http://' . $_SERVER['HTTP_HOST'] . __ROOT__.$picture['path']; - } - }else{ + } else { return 'http://' . $_SERVER['HTTP_HOST'] .__ROOT__.$picture['path']; - } + } } diff --git a/Application/Base/Service/GameSourceService.class.php b/Application/Base/Service/GameSourceService.class.php index 595b13c3b..5e88b72a3 100644 --- a/Application/Base/Service/GameSourceService.class.php +++ b/Application/Base/Service/GameSourceService.class.php @@ -328,7 +328,7 @@ class GameSourceService { public function uploadPackage($localFilePath, $distFilePath, $isDeleteLocal = false) { $isChunk = C('PACKAGE_CHUNK_ENABLED') ? true : false; - if (get_tool_status('oss_storage') == 1) { + if (C('OSS_STATUS')) { if ($isChunk) { return $this->uploadPackageChunk($localFilePath, $distFilePath, $isDeleteLocal); } else { diff --git a/Application/Base/Service/OssService.class.php b/Application/Base/Service/OssService.class.php index f6c563459..8d52cdced 100644 --- a/Application/Base/Service/OssService.class.php +++ b/Application/Base/Service/OssService.class.php @@ -12,23 +12,23 @@ class OssService { private $accessKeyId = ''; private $accessKeySecret = ''; - private $domain = ''; + private $endpoint = ''; private $isCName = false; private $bucket = ''; - private $bdDomain = ''; + private $domain = ''; private $client; private $errorMessage = ''; public function __construct() { Vendor('OSS.autoload'); - $this->accessKeyId = C('oss_storage.accesskeyid'); - $this->accessKeySecret = C('oss_storage.accesskeysecr'); - $this->domain = C('oss_storage.domain'); - $this->isCName = C('oss_storage.is_cname'); - $this->bdDomain = C('oss_storage.bd_domain'); - $this->bucket = C('oss_storage.bucket'); - $this->client = new OssClient($this->accessKeyId, $this->accessKeySecret, $this->domain, $this->isCName); + $this->accessKeyId = C('OSS_ACCESS_KEY_ID'); + $this->accessKeySecret = C('OSS_ACCESS_KEY_SECRET'); + $this->endpoint = C('OSS_ENDPOINT'); + $this->domain = C('OSS_DOMAIN'); + $this->isCName = C('OSS_IS_CNAME'); + $this->bucket = C('OSS_BUCKET'); + $this->client = new OssClient($this->accessKeyId, $this->accessKeySecret, $this->endpoint, $this->isCName); } public function upload($localFilePath, $saveFileName) @@ -106,18 +106,13 @@ class OssService { private function getUrl($saveFileName) { $url = ''; - if ($this->isCName) { - $url = 'http://' . $this->domain . '/' . $saveFileName; + /* if ($this->isCName) { + $url = 'http://' . $this->endpoint . '/' . $saveFileName; } else { - $url = 'https://' . $this->bucket . '.' . $this->domain . '/' . $saveFileName; + $url = 'https://' . $this->bucket . '.' . $this->endpoint . '/' . $saveFileName; $url = str_replace('-internal', '', $url); - } - /** - * @todo unknown - */ - if (!empty($this->bdDomain) && strlen($this->bdDomain) > 5) { - $url = $this->bdDomain . $saveFileName; - } + } */ + $url = $this->domain . '/' . $saveFileName; return $url; } } \ No newline at end of file diff --git a/Application/Common/Common/extend.php b/Application/Common/Common/extend.php index 3b74d0575..e774ef468 100644 --- a/Application/Common/Common/extend.php +++ b/Application/Common/Common/extend.php @@ -2345,14 +2345,10 @@ function get_child_ids($id){ } //获取图片连接 function icon_url($value){ - if (get_tool_status("oss_storage") == 1){ - $url=get_cover($value, 'path'); - }elseif(get_tool_status("qiniu_storage") == 1){ - $url=get_cover($value, 'path'); - }elseif(get_tool_status("cos_storage") == 1){ - $url=get_cover($value, 'path'); - }else{ - $url='http://' . $_SERVER['HTTP_HOST'] . get_cover($value, 'path'); + if (C('OSS_STATUS')){ + $url = get_cover($value, 'path'); + } else { + $url = 'http://' . $_SERVER['HTTP_HOST'] . get_cover($value, 'path'); } return $url; } diff --git a/Application/Common/Common/function.php b/Application/Common/Common/function.php index c7d4909d2..254db43cb 100644 --- a/Application/Common/Common/function.php +++ b/Application/Common/Common/function.php @@ -1016,30 +1016,12 @@ function get_cover($cover_id, $field = null, $root = 1, $flag = true) return ""; } $picture = M('Picture')->where(array('status' => 1))->getById($cover_id); - if (get_tool_status("oss_storage") == 1) { + if (C('OSS_STATUS')) { if (!empty($picture['oss_url'])) { return str_replace('http:', 'https:', $picture['oss_url']); } else { return 'https://' . $_SERVER['HTTP_HOST'] . __ROOT__ . $picture['path']; } - } elseif (get_tool_status("qiniu_storage") == 1) { - if (!empty($picture['url'])) { - return $picture['url']; - } else { - return '//' . $_SERVER['HTTP_HOST'] . __ROOT__ . $picture['path']; - } - } elseif (get_tool_status("cos_storage") == 1) { - if (!empty($picture['url'])) { - return $picture['url']; - } else { - return '//' . $_SERVER['HTTP_HOST'] . __ROOT__ . $picture['path']; - } - } elseif (get_tool_status("bos_storage") == 1) { - if (!empty($picture['bos_url'])) { - return $picture['bos_url']; - } else { - return '//' . $_SERVER['HTTP_HOST'] . __ROOT__ . $picture['path']; - } } else { if ($field == 'path') { if (!empty($picture['url']) && get_tool_status('qiniu_storage') == 1) { diff --git a/Application/Home/Model/PictureModel.class.php b/Application/Home/Model/PictureModel.class.php index d3a159ae4..4b979ae2a 100644 --- a/Application/Home/Model/PictureModel.class.php +++ b/Application/Home/Model/PictureModel.class.php @@ -10,6 +10,7 @@ namespace Home\Model; use Think\Model; use Think\Upload; +use Base\Service\OssService; /** * 图片模型 @@ -55,29 +56,14 @@ class PictureModel extends Model{ unset($info[$key]); } } - if (get_tool_status("oss_storage") == 1) { - $path = explode("/", $value['path']); - $to = "http://" . C("oss_storage.bucket") . "." . C("oss_storage.domain") . "/icon/" . $path[4]; - $to = str_replace('-internal', '', $to); - $updata['savename'] = $path[4]; - $updata['path'] = "." . $value['path']; - $oss = A('Oss'); - $oss->upload_game_pak_oss($updata); - $data_url['oss_url'] = $to; - $coo = $this->where(array('id' => $value['id']))->save($data_url); - } elseif (get_tool_status("qiniu_storage") == 1) {//七牛上传 - $path = explode("/", $value['path']); - $newName = $path[4]; - $QiNiu = A('QiNiu','Event'); - $value['url'] = $data_url['url'] = "http://".$QiNiu->upQiNiuFile($newName, ".".$value['path']); - $coo = $this->where(array('id' => $value['id']))->save($data_url); - } elseif(get_tool_status("bos_storage") == 1){ //上传到百度云 - $path = explode("/", $value['path']); - $updata['savename'] = $path[4]; - $updata['path'] = "." . $value['path']; - $bos =A('Bos'); - $bos ->upload_bos($updata); - $coo = $this->where(array('id' => $value['id']))->save($data_url); + if (C('OSS_STATUS')) { + $path = explode('/', $value['path']); + $saveFileName = 'icon/' . $path[4]; + $localFilePath = '.' . $value['path']; + $ossService = new OssService(); + $ossService->upload($localFilePath, $saveFileName); + $dataUrl['oss_url'] = $ossService->getUrl($saveFileName); + $coo = $this->where(['id' => $value['id']])->save($dataUrl); } } return $info; //文件上传成功 diff --git a/Application/Mobile/Common/function.php b/Application/Mobile/Common/function.php index af8944d8a..1fb99e42d 100644 --- a/Application/Mobile/Common/function.php +++ b/Application/Mobile/Common/function.php @@ -548,34 +548,15 @@ function get_img_url($cover_id){ return ""; } $picture = M('Picture')->where(array('status'=>1))->getById($cover_id); - if (get_tool_status("oss_storage") == 1) { + if (C('OSS_STATUS')) { if(!empty($picture['oss_url'])){ return $picture['oss_url']; }else{ return 'http://' . $_SERVER['HTTP_HOST'] . __ROOT__.$picture['path']; } - }elseif(get_tool_status("qiniu_storage") == 1){ - if(!empty($picture['url'])){ - return $picture['url']; - }else{ - return 'http://' . $_SERVER['HTTP_HOST'] . __ROOT__.$picture['path']; - } - }elseif(get_tool_status("cos_storage") == 1){ - if(!empty($picture['url'])){ - return $picture['url']; - }else{ - return 'http://' . $_SERVER['HTTP_HOST'] . __ROOT__.$picture['path']; - } - - }elseif(get_tool_status("bos_storage") == 1){ - if(!empty($picture['bos_url'])){ - return $picture['bos_url']; - }else{ - return 'http://' . $_SERVER['HTTP_HOST'] . __ROOT__.$picture['path']; - } - }else{ + }else{ return 'http://' . $_SERVER['HTTP_HOST'] .__ROOT__.$picture['path']; - } + } } /** diff --git a/Public/Home/images/FileController.class.php b/Public/Home/images/FileController.class.php index d6d0cc7fe..719b32945 100644 --- a/Public/Home/images/FileController.class.php +++ b/Public/Home/images/FileController.class.php @@ -9,6 +9,7 @@ namespace Admin\Controller; use OSS\OssClient; use Think\ShardUpload; +use Base\Service\OssService; /** * 文件控制器 * 主要用于下载模型的文件上传和下载 @@ -78,8 +79,8 @@ class FileController extends AdminController { } if(($path = $uploader->upload('file', $_POST)) !== false){ if(I('get.type') == "1"){ - $file_info = json_decode($path,true); - $this->upload_oss("Material/",$file_info['name'],$file_info['path'].'/'.$file_info['name']); + $file_info = json_decode($path, true); + $url = $this->uploadOss("Material/",$file_info['name'],$file_info['path'].'/'.$file_info['name']); $file_info['path'] = "http://".C('CND_ADDRESS')."/Material"; $path = json_encode($file_info); } @@ -170,93 +171,11 @@ class FileController extends AdminController { /** *上传到OSS */ - public function upload_oss($oss_path,$file_name,$file_path) + public function uploadOss($ossPath, $fileName,$filePath) { - /** - * 根据Config配置,得到一个OssClient实例 - */ - try { - Vendor('OSS.autoload'); - $ossClient = new \OSS\OssClient(C("oss_storage.accesskeyid"), C("oss_storage.accesskeysecr"), C("oss_storage.domain")); - } catch (OssException $e) { - $this->error($e->getMessage()); - } - - $oss_file_path = $oss_path . $file_name; - $avatar = $file_path; - try { - - $this->multiuploadFile($ossClient, C("oss_storage.bucket"), $oss_file_path, $avatar); - return true; - } catch (OssException $e) { - /* 返回JSON数据 */ - $this->error($e->getMessage()); - } - } - - public function multiuploadFile($ossClient, $bucket, $url, $file) - { - //$file = __FILE__; - $options = array(); - try { - #初始化分片上传文件 - $uploadId = $ossClient->initiateMultipartUpload($bucket, $url); - //$ossClient->multiuploadFile($bucket, $url, $file, $options); - } catch (OssException $e) { - printf(__FUNCTION__ . ": initiateMultipartUpload FAILED\n"); - printf($e->getMessage() . "\n"); - return; - } - /* - * step 2. 上传分片 - */ - $partSize = 5 * 1000 * 1024; - $uploadFile = $file; - $uploadFileSize = filesize($uploadFile); - $pieces = $ossClient->generateMultiuploadParts($uploadFileSize, $partSize); - $responseUploadPart = array(); - $uploadPosition = 0; - $isCheckMd5 = true; - foreach ($pieces as $i => $piece) { - $fromPos = $uploadPosition + (integer)$piece[$ossClient::OSS_SEEK_TO]; - $toPos = (integer)$piece[$ossClient::OSS_LENGTH] + $fromPos - 1; - $upOptions = array( - $ossClient::OSS_FILE_UPLOAD => $uploadFile, - $ossClient::OSS_PART_NUM => ($i + 1), - $ossClient::OSS_SEEK_TO => $fromPos, - $ossClient::OSS_LENGTH => $toPos - $fromPos + 1, - $ossClient::OSS_CHECK_MD5 => $isCheckMd5, - ); - if ($isCheckMd5) { - $contentMd5 = \OSS\Core\OssUtil::getMd5SumForFile($uploadFile, $fromPos, $toPos); - $upOptions[$ossClient::OSS_CONTENT_MD5] = $contentMd5; - } - //2. 将每一分片上传到OSS - try { - $responseUploadPart[] = $ossClient->uploadPart($bucket, $url, $uploadId, $upOptions); - } catch (OssException $e) { - printf(__FUNCTION__ . ": initiateMultipartUpload, uploadPart - part#{$i} FAILED\n"); - printf($e->getMessage() . "\n"); - return; - } - //printf(__FUNCTION__ . ": initiateMultipartUpload, uploadPart - part#{$i} OK\n"); - } - $uploadParts = array(); - foreach ($responseUploadPart as $i => $eTag) { - $uploadParts[] = array( - 'PartNumber' => ($i + 1), - 'ETag' => $eTag, - ); - } - /** - * step 3. 完成上传 - */ - try { - $a = $ossClient->completeMultipartUpload($bucket, $url, $uploadId, $uploadParts); - } catch (OssException $e) { - printf(__FUNCTION__ . ": completeMultipartUpload FAILED\n"); - printf($e->getMessage() . "\n"); - return; - } + $ossFilePath = $ossPath . $fileName; + $ossService = new OssService(); + $ossService->upload($filePath, $ossFilePath); + return $ossService->getUrl($ossFilePath); } } From e6c891a945b781bc845f4ffb7af1d45fad49d1f2 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Mon, 6 Jan 2020 14:21:51 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Base/Service/OssService.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Application/Base/Service/OssService.class.php b/Application/Base/Service/OssService.class.php index 8d52cdced..49f52c66e 100644 --- a/Application/Base/Service/OssService.class.php +++ b/Application/Base/Service/OssService.class.php @@ -103,7 +103,7 @@ class OssService { $this->client->deleteObject($this->bucket, $deleteFile); } - private function getUrl($saveFileName) + public function getUrl($saveFileName) { $url = ''; /* if ($this->isCName) { From fe68d8e8c943844d1e34a5b0a78b7452749f7f1a Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Mon, 6 Jan 2020 14:44:49 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9oss=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Model/PictureModel.class.php | 11 ++++++++--- Application/Home/Model/PictureModel.class.php | 9 +++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Application/Admin/Model/PictureModel.class.php b/Application/Admin/Model/PictureModel.class.php index 32ffa23cd..69e0dd3d0 100644 --- a/Application/Admin/Model/PictureModel.class.php +++ b/Application/Admin/Model/PictureModel.class.php @@ -75,9 +75,14 @@ class PictureModel extends Model{ $saveFileName = 'icon/' . $path[4]; $localFilePath = '.' . $value['path']; $ossService = new OssService(); - $ossService->upload($localFilePath, $saveFileName); - $dataUrl['oss_url'] = $ossService->getUrl($saveFileName); - $coo = $this->where(['id' => $value['id']])->save($dataUrl); + $result = $ossService->upload($localFilePath, $saveFileName); + if ($result['status']) { + $dataUrl['oss_url'] = $ossService->getUrl($saveFileName); + $coo = $this->where(['id' => $value['id']])->save($dataUrl); + } else { + $this->error = $result['message']; + return false; + } } } return $info; //文件上传成功 diff --git a/Application/Home/Model/PictureModel.class.php b/Application/Home/Model/PictureModel.class.php index 4b979ae2a..bdfdc8010 100644 --- a/Application/Home/Model/PictureModel.class.php +++ b/Application/Home/Model/PictureModel.class.php @@ -62,8 +62,13 @@ class PictureModel extends Model{ $localFilePath = '.' . $value['path']; $ossService = new OssService(); $ossService->upload($localFilePath, $saveFileName); - $dataUrl['oss_url'] = $ossService->getUrl($saveFileName); - $coo = $this->where(['id' => $value['id']])->save($dataUrl); + if ($result['status']) { + $dataUrl['oss_url'] = $ossService->getUrl($saveFileName); + $coo = $this->where(['id' => $value['id']])->save($dataUrl); + } else { + $this->error = $result['message']; + return false; + } } } return $info; //文件上传成功 From 04fccce6dc31c486a1ad3fc829d714ce6854ba37 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Mon, 6 Jan 2020 15:51:55 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E7=BD=91=E7=BB=9C=E8=AF=B7=E6=B1=82=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Base/Service/GameSourceService.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Application/Base/Service/GameSourceService.class.php b/Application/Base/Service/GameSourceService.class.php index 5e88b72a3..4af55713c 100644 --- a/Application/Base/Service/GameSourceService.class.php +++ b/Application/Base/Service/GameSourceService.class.php @@ -349,7 +349,7 @@ class GameSourceService { { $client = new Client([ 'base_uri' => C('PACKAGE_CHUNK_URL'), - 'timeout' => 10.0, + 'timeout' => 30.0, ]); $response = $client->post('/upload', [ 'verify' => false,