Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6 into develop
正在显示
4 个修改的文件
包含
57 行增加
和
30 行删除
| @@ -24,16 +24,22 @@ class CountController extends BaseController | @@ -24,16 +24,22 @@ class CountController extends BaseController | ||
| 24 | $data = []; | 24 | $data = []; |
| 25 | //TODO::昨日数据统计 | 25 | //TODO::昨日数据统计 |
| 26 | $data['yesterday'] = $countLogic->yesterday_count(); | 26 | $data['yesterday'] = $countLogic->yesterday_count(); |
| 27 | + var_dump(111111); | ||
| 27 | //TODO::全球搜方案信息 | 28 | //TODO::全球搜方案信息 |
| 28 | $data['scheme_info'] = $countLogic->scheme_info(); | 29 | $data['scheme_info'] = $countLogic->scheme_info(); |
| 30 | + var_dump(222); | ||
| 29 | //TODO::网站访问量统计 | 31 | //TODO::网站访问量统计 |
| 30 | $data['total_visit'] = $countLogic->total_count(isset($data['yesterday']['inquiry_num']) ? $data['yesterday']['inquiry_num'] : ''); | 32 | $data['total_visit'] = $countLogic->total_count(isset($data['yesterday']['inquiry_num']) ? $data['yesterday']['inquiry_num'] : ''); |
| 33 | + var_dump(3333); | ||
| 31 | //TODO::关键字排名数据 | 34 | //TODO::关键字排名数据 |
| 32 | $data['keyword_data'] = $countLogic->keyword_data_count(); | 35 | $data['keyword_data'] = $countLogic->keyword_data_count(); |
| 36 | + var_dump(4444); | ||
| 33 | //TODO::相关数据统计 | 37 | //TODO::相关数据统计 |
| 34 | $data['with_data'] = $countLogic->with_data_count(); | 38 | $data['with_data'] = $countLogic->with_data_count(); |
| 39 | + var_dump(555); | ||
| 35 | //TODO::30天pv,ip统计 | 40 | //TODO::30天pv,ip统计 |
| 36 | $data['visit_data'] = $countLogic->visit_data_count(); | 41 | $data['visit_data'] = $countLogic->visit_data_count(); |
| 42 | + var_dump(666); | ||
| 37 | //TODO::询盘国家统计 | 43 | //TODO::询盘国家统计 |
| 38 | $data['country_data'] = json_decode($data['yesterday']['country']); | 44 | $data['country_data'] = json_decode($data['yesterday']['country']); |
| 39 | //TODO::来源排名 | 45 | //TODO::来源排名 |
| @@ -142,8 +142,7 @@ class FileController | @@ -142,8 +142,7 @@ class FileController | ||
| 142 | 'file.required'=>'必须填写', | 142 | 'file.required'=>'必须填写', |
| 143 | ]); | 143 | ]); |
| 144 | $files = $this->request->file('file'); | 144 | $files = $this->request->file('file'); |
| 145 | - $size = $files->getSize(); | ||
| 146 | - $file_type = $files->getClientOriginalExtension(); | 145 | + |
| 147 | if (empty($files)) { | 146 | if (empty($files)) { |
| 148 | $this->response('没有上传的文件!', 400); | 147 | $this->response('没有上传的文件!', 400); |
| 149 | } | 148 | } |
| @@ -152,6 +151,8 @@ class FileController | @@ -152,6 +151,8 @@ class FileController | ||
| 152 | if ($type == 'multi') { | 151 | if ($type == 'multi') { |
| 153 | return $this->multi($files); | 152 | return $this->multi($files); |
| 154 | } else { | 153 | } else { |
| 154 | + $size = $files->getSize(); | ||
| 155 | + $file_type = $files->getClientOriginalExtension(); | ||
| 155 | return $this->single($files,$size,$file_type); | 156 | return $this->single($files,$size,$file_type); |
| 156 | } | 157 | } |
| 157 | } | 158 | } |
| @@ -223,7 +224,6 @@ class FileController | @@ -223,7 +224,6 @@ class FileController | ||
| 223 | * @time :2023/6/17 16:32 | 224 | * @time :2023/6/17 16:32 |
| 224 | */ | 225 | */ |
| 225 | private function multi($files) { | 226 | private function multi($files) { |
| 226 | - $save_data = []; | ||
| 227 | $data = []; | 227 | $data = []; |
| 228 | foreach ($files as $file) { | 228 | foreach ($files as $file) { |
| 229 | $fileModel = new File(); | 229 | $fileModel = new File(); |
| @@ -235,24 +235,27 @@ class FileController | @@ -235,24 +235,27 @@ class FileController | ||
| 235 | } | 235 | } |
| 236 | $url = $this->config['root'].'/'.$this->path; | 236 | $url = $this->config['root'].'/'.$this->path; |
| 237 | $fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension(); | 237 | $fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension(); |
| 238 | - $res = $file->move($url,$fileName); | ||
| 239 | - if ($res === false) { | ||
| 240 | - return $this->response($file->getError(), Code::USER_ERROR); | 238 | + //同步数据到cos |
| 239 | + if($this->upload_location == 1){ | ||
| 240 | + $cosService = new CosService(); | ||
| 241 | + $is_cos = 1;//上传到cos | ||
| 242 | + $cosService->uploadFile($files,$this->path,$fileName); | ||
| 243 | + }else{ | ||
| 244 | + $is_cos = 0; | ||
| 245 | + $res = $files->move($url,$fileName); | ||
| 246 | + if ($res === false) { | ||
| 247 | + return $this->response($files->getError(), Code::USER_ERROR); | ||
| 248 | + } | ||
| 241 | } | 249 | } |
| 242 | - $save_data[] = [ | ||
| 243 | - 'path' => $this->path.'/'.$fileName, | ||
| 244 | - 'created_at' => date('Y-m-d H:i:s',time()), | ||
| 245 | - 'size' => $res->getSize(), | ||
| 246 | - 'hash' => $hash, | ||
| 247 | - 'type'=>$files->getClientOriginalExtension(), | ||
| 248 | - 'refer'=>$this->param['refer'] | ||
| 249 | - ]; | 250 | + $size = $file->getSize(); |
| 251 | + $file_type = $file->getClientOriginalExtension(); | ||
| 252 | + $this->saveMysql($fileModel,$size,$file_type,$fileName,$hash,$is_cos); | ||
| 250 | $data[] = $hash; | 253 | $data[] = $hash; |
| 251 | } | 254 | } |
| 252 | - $fileModel->insert($save_data); | ||
| 253 | return $this->response('资源',Code::SUCCESS,['file'=>$data]); | 255 | return $this->response('资源',Code::SUCCESS,['file'=>$data]); |
| 254 | } | 256 | } |
| 255 | 257 | ||
| 258 | + | ||
| 256 | /** | 259 | /** |
| 257 | * @param $msg | 260 | * @param $msg |
| 258 | * @param string $code | 261 | * @param string $code |
| @@ -41,6 +41,7 @@ class ImageController extends Controller | @@ -41,6 +41,7 @@ class ImageController extends Controller | ||
| 41 | public $cache = '';//缓存数据 | 41 | public $cache = '';//缓存数据 |
| 42 | 42 | ||
| 43 | public $upload_location = 0;//是否同步到cos | 43 | public $upload_location = 0;//是否同步到cos |
| 44 | + //上传图片类型 | ||
| 44 | public $image_type = [ | 45 | public $image_type = [ |
| 45 | 1 => 'image_product', | 46 | 1 => 'image_product', |
| 46 | 2 => 'image_news', | 47 | 2 => 'image_news', |
| @@ -157,15 +158,15 @@ class ImageController extends Controller | @@ -157,15 +158,15 @@ class ImageController extends Controller | ||
| 157 | return $this->response('图片资源',Code::SUCCESS,['image'=>$hash]); | 158 | return $this->response('图片资源',Code::SUCCESS,['image'=>$hash]); |
| 158 | } | 159 | } |
| 159 | $url = $this->config['root'].$this->path; | 160 | $url = $this->config['root'].$this->path; |
| 160 | - $fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension(); | ||
| 161 | - //同步数据到cos | 161 | + $fileName = uniqid().rand(10000,99999).'.'.$image_type; |
| 162 | + //上传到cos | ||
| 162 | if($this->upload_location == 1){ | 163 | if($this->upload_location == 1){ |
| 163 | $cosService = new CosService(); | 164 | $cosService = new CosService(); |
| 164 | $is_cos = 1;//上传到cos | 165 | $is_cos = 1;//上传到cos |
| 165 | $cosService->uploadFile($files,$this->path,$fileName); | 166 | $cosService->uploadFile($files,$this->path,$fileName); |
| 166 | }else{ | 167 | }else{ |
| 167 | $res = $files->move($url,$fileName); | 168 | $res = $files->move($url,$fileName); |
| 168 | - $is_cos = 0;//上传到cos | 169 | + $is_cos = 0; |
| 169 | if ($res === false) { | 170 | if ($res === false) { |
| 170 | return $this->response($files->getError(), Code::USER_ERROR); | 171 | return $this->response($files->getError(), Code::USER_ERROR); |
| 171 | } | 172 | } |
| @@ -223,7 +224,7 @@ class ImageController extends Controller | @@ -223,7 +224,7 @@ class ImageController extends Controller | ||
| 223 | * @time :2023/6/17 16:31 | 224 | * @time :2023/6/17 16:31 |
| 224 | */ | 225 | */ |
| 225 | private function multi(&$files) { | 226 | private function multi(&$files) { |
| 226 | - $save_data = []; | 227 | + $save_data = [];//保存数据 |
| 227 | $data = []; | 228 | $data = []; |
| 228 | foreach ($files as $file) { | 229 | foreach ($files as $file) { |
| 229 | $size = $file->getSize(); | 230 | $size = $file->getSize(); |
| @@ -243,21 +244,14 @@ class ImageController extends Controller | @@ -243,21 +244,14 @@ class ImageController extends Controller | ||
| 243 | $is_cos = 1;//上传到cos | 244 | $is_cos = 1;//上传到cos |
| 244 | $cosService->uploadFile($file,$this->path,$fileName); | 245 | $cosService->uploadFile($file,$this->path,$fileName); |
| 245 | }else{ | 246 | }else{ |
| 247 | + $is_cos = 0; | ||
| 246 | $res = $file->move($url,$fileName); | 248 | $res = $file->move($url,$fileName); |
| 247 | if ($res === false) { | 249 | if ($res === false) { |
| 248 | return $this->response($file->getError(), Code::USER_ERROR); | 250 | return $this->response($file->getError(), Code::USER_ERROR); |
| 249 | } | 251 | } |
| 250 | } | 252 | } |
| 251 | - $save_data[] = [ | ||
| 252 | - 'path' => $this->path.'/'.$fileName, | ||
| 253 | - 'created_at' => date('Y-m-d H:i:s',time()), | ||
| 254 | - 'updated_at'=>date('Y-m-d H:i:s',time()), | ||
| 255 | - 'size' => $size, | ||
| 256 | - 'hash' => $hash, | ||
| 257 | - 'type'=>$image_type, | ||
| 258 | - 'refer'=>$this->param['refer'] ?? 0, | ||
| 259 | - 'is_cos'=>$is_cos ?? 0 | ||
| 260 | - ]; | 253 | + //批量存储 |
| 254 | + $save_data = $this->saveMysqlAll($save_data,$fileName,$size,$hash,$image_type,$is_cos); | ||
| 261 | $data[] = ['image'=>$hash]; | 255 | $data[] = ['image'=>$hash]; |
| 262 | } | 256 | } |
| 263 | $imageModel->insert($save_data); | 257 | $imageModel->insert($save_data); |
| @@ -265,6 +259,31 @@ class ImageController extends Controller | @@ -265,6 +259,31 @@ class ImageController extends Controller | ||
| 265 | } | 259 | } |
| 266 | 260 | ||
| 267 | /** | 261 | /** |
| 262 | + * @param $save_data | ||
| 263 | + * @param $fileName | ||
| 264 | + * @param $size | ||
| 265 | + * @param $hash | ||
| 266 | + * @param $image_type | ||
| 267 | + * @remark :批量拼接数据 | ||
| 268 | + * @name :saveMysqlAll | ||
| 269 | + * @author :lyh | ||
| 270 | + * @method :post | ||
| 271 | + * @time :2023/7/20 9:26 | ||
| 272 | + */ | ||
| 273 | + public function saveMysqlAll(&$save_data,$fileName,$size,$hash,$image_type,$is_cos){ | ||
| 274 | + $save_data[] = [ | ||
| 275 | + 'path' => $this->path.'/'.$fileName, | ||
| 276 | + 'created_at' => date('Y-m-d H:i:s',time()), | ||
| 277 | + 'updated_at'=>date('Y-m-d H:i:s',time()), | ||
| 278 | + 'size' => $size, | ||
| 279 | + 'hash' => $hash, | ||
| 280 | + 'type'=>$image_type, | ||
| 281 | + 'refer'=>$this->param['refer'] ?? 0, | ||
| 282 | + 'is_cos'=>$is_cos ?? 0 | ||
| 283 | + ]; | ||
| 284 | + return $save_data; | ||
| 285 | + } | ||
| 286 | + /** | ||
| 268 | * @param $filename | 287 | * @param $filename |
| 269 | * @remark :下载 | 288 | * @remark :下载 |
| 270 | * @name :download | 289 | * @name :download |
-
请 注册 或 登录 后发表评论