作者 赵彬吉

Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6 into develop

1 <?php 1 <?php
2 2
  3 +use App\Models\File\Image;
  4 +use App\Services\CosService;
3 use App\Utils\LogUtils; 5 use App\Utils\LogUtils;
4 use GuzzleHttp\Client; 6 use GuzzleHttp\Client;
5 use GuzzleHttp\Exception\GuzzleException; 7 use GuzzleHttp\Exception\GuzzleException;
@@ -405,28 +407,36 @@ if (!function_exists('getDateArray')) { @@ -405,28 +407,36 @@ if (!function_exists('getDateArray')) {
405 return $days; 407 return $days;
406 } 408 }
407 } 409 }
408 -/**  
409 - * @param $str  
410 - * @remark :判断是否为中文  
411 - * @name :isChinese  
412 - * @author :lyh  
413 - * @method :post  
414 - * @time :2023/6/28 16:15  
415 - */  
416 -function isChinese($str) {  
417 - return preg_match('/^[\x{4e00}-\x{9fa5}]+$/u', $str);  
418 -}  
419 410
420 -/**  
421 - * @param $str  
422 - * @remark :判断是否为英文  
423 - * @name :isEnglish  
424 - * @author :lyh  
425 - * @method :post  
426 - * @time :2023/6/28 16:15  
427 - */  
428 -function isEnglish($str) {  
429 - return preg_match('/^[a-zA-Z]+$/u', $str); 411 +if (!function_exists('getImageUrl')) {
  412 + /**
  413 + * @remark :获取图片链接
  414 + * @name :getImageUrl
  415 + * @author :lyh
  416 + * @method :post
  417 + * @time :2023/7/20 16:46
  418 + */
  419 + function getImageUrl($hash){
  420 + if(is_array($hash)){
  421 + foreach ($hash as $v){
  422 + $url[] = getImageUrl($v);
  423 + }
  424 + }else{
  425 + $imageModel = new Image();
  426 + $info = $imageModel->read(['hash'=>$hash]);
  427 + if(!empty($info)){
  428 + if($info['is_cos'] == 1){
  429 + $cos = new CosService();
  430 + $url = $cos->getImageUrl($info['path']);
  431 + }else{
  432 + $url = url('a/image/'.$info['hash']);
  433 + }
  434 + }else{
  435 + $url = $hash;
  436 + }
  437 + }
  438 + return $url;
  439 + }
430 } 440 }
431 441
432 /** 442 /**
@@ -137,36 +137,6 @@ class BaseController extends Controller @@ -137,36 +137,6 @@ class BaseController extends Controller
137 throw new HttpResponseException($response); 137 throw new HttpResponseException($response);
138 } 138 }
139 139
140 -  
141 - /**  
142 - * @remark :获取图片链接  
143 - * @name :getImageUrl  
144 - * @author :lyh  
145 - * @method :post  
146 - * @time :2023/7/20 16:46  
147 - */  
148 - public function getImageUrl($hash){  
149 - if(is_array($hash)){  
150 - foreach ($hash as $k => $v){  
151 - $url[] = $this->getImageUrl($v);  
152 - }  
153 - }else{  
154 - $imageModel = new Image();  
155 - $info = $imageModel->read(['hash'=>$hash]);  
156 - if(!empty($info)){  
157 - if($info['is_cos'] == 1){  
158 - $cos = new CosService();  
159 - $url = $cos->getImageUrl($info['path']);  
160 - }else{  
161 - $url = url('a/image/'.$info['hash']);  
162 - }  
163 - }else{  
164 - $url = $hash;  
165 - }  
166 - }  
167 - return $url;  
168 - }  
169 -  
170 /** 140 /**
171 * @remark :获取文件交接链接 141 * @remark :获取文件交接链接
172 * @name :getImageUrl 142 * @name :getImageUrl
@@ -20,9 +20,9 @@ class HrController extends BaseController @@ -20,9 +20,9 @@ class HrController extends BaseController
20 $lists = $logic->getHrList($this->map,$this->page,$this->row,$this->order); 20 $lists = $logic->getHrList($this->map,$this->page,$this->row,$this->order);
21 if(!empty($lists['list'])){ 21 if(!empty($lists['list'])){
22 foreach ($lists['list'] as $k => $v){ 22 foreach ($lists['list'] as $k => $v){
23 - $v['photo_gallery_link'] = $this->getImageUrl(json_decode($v['photo_gallery']));  
24 - $v['id_card_gallery_link'] = $this->getImageUrl(json_decode($v['id_card_gallery']));  
25 - $v['certificate_gallery_link'] = $this->getImageUrl(json_decode($v['certificate_gallery'])); 23 + $v['photo_gallery_link'] = getImageUrl(json_decode($v['photo_gallery']));
  24 + $v['id_card_gallery_link'] = getImageUrl(json_decode($v['id_card_gallery']));
  25 + $v['certificate_gallery_link'] = getImageUrl(json_decode($v['certificate_gallery']));
26 $lists['list'][$k] = $v; 26 $lists['list'][$k] = $v;
27 } 27 }
28 } 28 }
@@ -36,9 +36,9 @@ class HrController extends BaseController @@ -36,9 +36,9 @@ class HrController extends BaseController
36 'id.required' => 'ID不能为空' 36 'id.required' => 'ID不能为空'
37 ]); 37 ]);
38 $info = $logic->getHrInfo($this->param['id']); 38 $info = $logic->getHrInfo($this->param['id']);
39 - $info['photo_gallery_link'] = $this->getImageUrl($info['photo_gallery']);  
40 - $info['id_card_gallery_link'] = $this->getImageUrl($info['id_card_gallery']);  
41 - $info['certificate_gallery_link'] = $this->getImageUrl($info['certificate_gallery']); 39 + $info['photo_gallery_link'] = getImageUrl($info['photo_gallery']);
  40 + $info['id_card_gallery_link'] = getImageUrl($info['id_card_gallery']);
  41 + $info['certificate_gallery_link'] = getImageUrl($info['certificate_gallery']);
42 return $this->success($info); 42 return $this->success($info);
43 } 43 }
44 44
@@ -67,6 +67,7 @@ class InquiryInfoController extends BaseController @@ -67,6 +67,7 @@ class InquiryInfoController extends BaseController
67 'type.required' => '类型不能为空', 67 'type.required' => '类型不能为空',
68 ]); 68 ]);
69 } 69 }
  70 +
70 /** 71 /**
71 * @remark :保存询盘信息 72 * @remark :保存询盘信息
72 * @name :save 73 * @name :save
@@ -232,35 +232,6 @@ class BaseController extends Controller @@ -232,35 +232,6 @@ class BaseController extends Controller
232 } 232 }
233 233
234 /** 234 /**
235 - * @remark :获取图片链接  
236 - * @name :getImageUrl  
237 - * @author :lyh  
238 - * @method :post  
239 - * @time :2023/7/20 16:46  
240 - */  
241 - public function getImageUrl($hash){  
242 - if(is_array($hash)){  
243 - foreach ($hash as $k => $v){  
244 - $url[] = $this->getImageUrl($v);  
245 - }  
246 - }else{  
247 - $imageModel = new Image();  
248 - $info = $imageModel->read(['hash'=>$hash]);  
249 - if(!empty($info)){  
250 - if($info['is_cos'] == 1){  
251 - $cos = new CosService();  
252 - $url = $cos->getImageUrl($info['path']);  
253 - }else{  
254 - $url = url('a/image/'.$info['hash']);  
255 - }  
256 - }else{  
257 - $url = $hash;  
258 - }  
259 - }  
260 - return $url;  
261 - }  
262 -  
263 - /**  
264 * @remark :获取文件交接链接 235 * @remark :获取文件交接链接
265 * @name :getImageUrl 236 * @name :getImageUrl
266 * @author :lyh 237 * @author :lyh
@@ -34,7 +34,7 @@ class BlogController extends BaseController @@ -34,7 +34,7 @@ class BlogController extends BaseController
34 $v = $blogLabelLogic->get_label_name($v); 34 $v = $blogLabelLogic->get_label_name($v);
35 $v['route'] = RouteMap::getRoute(RouteMap::SOURCE_BLOG, $v['id'], $this->user['project_id']); 35 $v['route'] = RouteMap::getRoute(RouteMap::SOURCE_BLOG, $v['id'], $this->user['project_id']);
36 $v['url'] = $this->getProjectDomain() . $v['route']; 36 $v['url'] = $this->getProjectDomain() . $v['route'];
37 - $v['image_link'] = $this->getImageUrl($v['image']); 37 + $v['image_link'] = getImageUrl($v['image']);
38 $lists['list'][$k] = $v; 38 $lists['list'][$k] = $v;
39 } 39 }
40 } 40 }
@@ -78,7 +78,7 @@ class BlogController extends BaseController @@ -78,7 +78,7 @@ class BlogController extends BaseController
78 $info = $blogLogic->blog_info(); 78 $info = $blogLogic->blog_info();
79 $info['route'] = RouteMap::getRoute(RouteMap::SOURCE_BLOG, $info['id'], $this->user['project_id']); 79 $info['route'] = RouteMap::getRoute(RouteMap::SOURCE_BLOG, $info['id'], $this->user['project_id']);
80 $info['url'] = $this->getProjectDomain() . $info['route']; 80 $info['url'] = $this->getProjectDomain() . $info['route'];
81 - $info['image_link'] = $this->getImageUrl($info['image']); 81 + $info['image_link'] = getImageUrl($info['image']);
82 $this->response('success',Code::SUCCESS,$info); 82 $this->response('success',Code::SUCCESS,$info);
83 } 83 }
84 84
@@ -32,7 +32,7 @@ class NewsController extends BaseController @@ -32,7 +32,7 @@ class NewsController extends BaseController
32 $v = $newsCategoryLogic->get_category_name($v); 32 $v = $newsCategoryLogic->get_category_name($v);
33 $v['route'] = RouteMap::getRoute(RouteMap::SOURCE_NEWS, $v['id'], $this->user['project_id']); 33 $v['route'] = RouteMap::getRoute(RouteMap::SOURCE_NEWS, $v['id'], $this->user['project_id']);
34 $v['url'] = $this->getProjectDomain() . $v['route']; 34 $v['url'] = $this->getProjectDomain() . $v['route'];
35 - $v['image_link'] = $this->getImageUrl($v['image']); 35 + $v['image_link'] = getImageUrl($v['image']);
36 $lists['list'][$k] = $v; 36 $lists['list'][$k] = $v;
37 } 37 }
38 } 38 }
@@ -75,7 +75,7 @@ class NewsController extends BaseController @@ -75,7 +75,7 @@ class NewsController extends BaseController
75 $info = $newsLogic->news_info(); 75 $info = $newsLogic->news_info();
76 $info['route'] = RouteMap::getRoute(RouteMap::SOURCE_NEWS, $info['id'], $this->user['project_id']); 76 $info['route'] = RouteMap::getRoute(RouteMap::SOURCE_NEWS, $info['id'], $this->user['project_id']);
77 $info['url'] = $this->getProjectDomain() . $info['route']; 77 $info['url'] = $this->getProjectDomain() . $info['route'];
78 - $info['image_link'] = $this->getImageUrl($info['image']); 78 + $info['image_link'] = getImageUrl($info['image']);
79 $this->response('success',Code::SUCCESS,$info); 79 $this->response('success',Code::SUCCESS,$info);
80 } 80 }
81 /** 81 /**
@@ -55,7 +55,7 @@ class ProductController extends BaseController @@ -55,7 +55,7 @@ class ProductController extends BaseController
55 $map[] = ['status', $this->param['status']]; 55 $map[] = ['status', $this->param['status']];
56 } 56 }
57 $sort = ['id' => 'desc']; 57 $sort = ['id' => 'desc'];
58 - $data = $logic->getList($map, $sort, ['id', 'project_id', 'title', 'thumb', 'category_id', 'keyword_id', 'status', 'created_uid', 'created_at', 'updated_at']); 58 + $data = $logic->getList($map, $sort, ['id', 'project_id', 'title', 'thumb', 'product_type' ,'category_id', 'keyword_id', 'status', 'created_uid', 'created_at', 'updated_at']);
59 return $this->success($data); 59 return $this->success($data);
60 } 60 }
61 61
@@ -24,7 +24,7 @@ class ProofreadingController extends BaseController @@ -24,7 +24,7 @@ class ProofreadingController extends BaseController
24 $lists = $proofreadingLogic->proofreadingList($this->map,$this->page,$this->row); 24 $lists = $proofreadingLogic->proofreadingList($this->map,$this->page,$this->row);
25 if(!empty($lists['list']) && ($this->param['type'] == $this::TYPE_IMAGE)){ 25 if(!empty($lists['list']) && ($this->param['type'] == $this::TYPE_IMAGE)){
26 foreach ($lists['list'] as $k => $v){ 26 foreach ($lists['list'] as $k => $v){
27 - $lists['list'][$k]['image_link'] = $this->getImageUrl($v['translate']); 27 + $lists['list'][$k]['image_link'] = getImageUrl($v['translate']);
28 } 28 }
29 } 29 }
30 $this->response('success',Code::SUCCESS,$lists); 30 $this->response('success',Code::SUCCESS,$lists);
@@ -22,7 +22,7 @@ class WebSettingServiceController extends BaseController @@ -22,7 +22,7 @@ class WebSettingServiceController extends BaseController
22 $lists = $webSettingServiceLogic->setting_service_list(); 22 $lists = $webSettingServiceLogic->setting_service_list();
23 foreach ($lists as $k => $v){ 23 foreach ($lists as $k => $v){
24 if($v['type'] == self::TYPE_CODE){ 24 if($v['type'] == self::TYPE_CODE){
25 - $v['values_link'] = $this->getImageUrl($v['values']); 25 + $v['values_link'] = getImageUrl($v['values']);
26 $lists[$k] = $v; 26 $lists[$k] = $v;
27 } 27 }
28 } 28 }
@@ -20,7 +20,7 @@ class BTemplateController extends BaseController @@ -20,7 +20,7 @@ class BTemplateController extends BaseController
20 $lists = $BTemplateLogic->publicTemplateLists($this->map,$this->page,$this->row,$this->order); 20 $lists = $BTemplateLogic->publicTemplateLists($this->map,$this->page,$this->row,$this->order);
21 if(!empty($lists) && !empty($lists['list'])){ 21 if(!empty($lists) && !empty($lists['list'])){
22 foreach ($lists['list'] as $k => &$v){ 22 foreach ($lists['list'] as $k => &$v){
23 - $v['image_link'] = $this->getImageUrl($v['image']); 23 + $v['image_link'] = getImageUrl($v['image']);
24 $lists['list'][$k] = $v; 24 $lists['list'][$k] = $v;
25 } 25 }
26 } 26 }
@@ -35,7 +35,7 @@ class FileController @@ -35,7 +35,7 @@ class FileController
35 public $token = '';//token 35 public $token = '';//token
36 36
37 public $cache = '';//缓存数据 37 public $cache = '';//缓存数据
38 - public $upload_location = 1; 38 + public $upload_location = 0;
39 public $file_type = [ 39 public $file_type = [
40 2 => 'other',//其他 40 2 => 'other',//其他
41 1 => 'video',//视频 41 1 => 'video',//视频
@@ -47,8 +47,6 @@ class FileController @@ -47,8 +47,6 @@ class FileController
47 $this->param = $this->request->all(); 47 $this->param = $this->request->all();
48 $this->config = config('filesystems.disks.upload'); 48 $this->config = config('filesystems.disks.upload');
49 $this->uploads = config('upload.default_file'); 49 $this->uploads = config('upload.default_file');
50 - $this->token = $this->request->header('token');  
51 - $this->cache = Cache::get($this->token);  
52 } 50 }
53 51
54 /** 52 /**
@@ -77,8 +75,7 @@ class FileController @@ -77,8 +75,7 @@ class FileController
77 $size = $info['size']; 75 $size = $info['size'];
78 header("Content-Length: ".$size); 76 header("Content-Length: ".$size);
79 // 设置Content-Type头部 77 // 设置Content-Type头部
80 - header("Content-Type: video/mp4");  
81 - // 发送完整文件 78 + header("Content-Type: {$info['mime']}");
82 readfile($path); 79 readfile($path);
83 exit; 80 exit;
84 } 81 }
@@ -108,7 +105,8 @@ class FileController @@ -108,7 +105,8 @@ class FileController
108 } else { 105 } else {
109 $size = $files->getSize(); 106 $size = $files->getSize();
110 $file_type = $files->getClientOriginalExtension(); 107 $file_type = $files->getClientOriginalExtension();
111 - return $this->single($files,$size,$file_type); 108 + $mime = $files->getMimeType();
  109 + return $this->single($files,$size,$file_type,$mime);
112 } 110 }
113 } 111 }
114 112
@@ -119,7 +117,7 @@ class FileController @@ -119,7 +117,7 @@ class FileController
119 * @method :post 117 * @method :post
120 * @time :2023/6/17 16:32 118 * @time :2023/6/17 16:32
121 */ 119 */
122 - public function single(&$files,$size,$file_type){ 120 + public function single(&$files,$size,$file_type,$mime = ''){
123 $hash = hash_file('md5', $files->getPathname()); 121 $hash = hash_file('md5', $files->getPathname());
124 //查看文件是否存在 122 //查看文件是否存在
125 $fileModel = new File(); 123 $fileModel = new File();
@@ -139,7 +137,7 @@ class FileController @@ -139,7 +137,7 @@ class FileController
139 return $this->response($files->getError(), Code::USER_ERROR); 137 return $this->response($files->getError(), Code::USER_ERROR);
140 } 138 }
141 } 139 }
142 - $this->saveMysql($fileModel,$size,$file_type,$fileName,$hash,$this->upload_location); 140 + $this->saveMysql($fileModel,$size,$file_type,$fileName,$hash,$this->upload_location,$mime);
143 return $this->response('资源',Code::SUCCESS,$this->responseData($fileModel,$hash)); 141 return $this->response('资源',Code::SUCCESS,$this->responseData($fileModel,$hash));
144 } 142 }
145 143
@@ -150,7 +148,7 @@ class FileController @@ -150,7 +148,7 @@ class FileController
150 * @method :post 148 * @method :post
151 * @time :2023/7/19 16:38 149 * @time :2023/7/19 16:38
152 */ 150 */
153 - public function saveMysql(&$fileModel,$size,$image_type,$fileName,$hash,$is_cos = 0){ 151 + public function saveMysql(&$fileModel,$size,$image_type,$fileName,$hash,$is_cos = 0,$mime = ''){
154 $data = [ 152 $data = [
155 'path' => $this->path.'/'.$fileName, 153 'path' => $this->path.'/'.$fileName,
156 'created_at' => date('Y-m-d H:i:s',time()), 154 'created_at' => date('Y-m-d H:i:s',time()),
@@ -158,7 +156,8 @@ class FileController @@ -158,7 +156,8 @@ class FileController
158 'hash' => $hash, 156 'hash' => $hash,
159 'type'=>$image_type, 157 'type'=>$image_type,
160 'refer'=>$this->param['refer'] ?? 1, 158 'refer'=>$this->param['refer'] ?? 1,
161 - 'is_cos'=>$is_cos 159 + 'is_cos'=>$is_cos,
  160 + 'mime'=>$mime,
162 ]; 161 ];
163 $rs = $fileModel->add($data); 162 $rs = $fileModel->add($data);
164 if ($rs === false) { 163 if ($rs === false) {
@@ -198,7 +197,8 @@ class FileController @@ -198,7 +197,8 @@ class FileController
198 } 197 }
199 } 198 }
200 $size = $file->getSize(); 199 $size = $file->getSize();
201 - $this->saveMysql($fileModel,$size,$file_type,$fileName,$hash,$this->upload_location); 200 + $mime = $file->getMimeType();
  201 + $this->saveMysql($fileModel,$size,$file_type,$fileName,$hash,$this->upload_location,$mime);
202 $data[] = $this->responseData($fileModel,$hash); 202 $data[] = $this->responseData($fileModel,$hash);
203 } 203 }
204 $this->response('资源',Code::SUCCESS,$data); 204 $this->response('资源',Code::SUCCESS,$data);
@@ -269,15 +269,17 @@ class FileController @@ -269,15 +269,17 @@ class FileController
269 if(isset($this->param['refer_type']) && $this->param['refer_type'] == 1){ 269 if(isset($this->param['refer_type']) && $this->param['refer_type'] == 1){
270 $this->path = $this->uploads['path_a'].'/'.$this->file_type[$this->param['refer']].'/'.date('Y-m'); 270 $this->path = $this->uploads['path_a'].'/'.$this->file_type[$this->param['refer']].'/'.date('Y-m');
271 }else{ 271 }else{
272 - //B端上传  
273 - if(isset($this->param['upload_method']) && $this->param['upload_method'] == 1){  
274 - //强制上传本地配置  
275 - $this->upload_location = 0;  
276 - }else{ 272 + //获取当前登录用户详情
  273 + $this->token = $this->request->header('token');
  274 + $this->cache = Cache::get($this->token);
  275 + //B端上传,upload_method 为 1时 强制上传到本地
  276 + if(!isset($this->param['upload_method'])) {
277 //根据项目上传标识区分上传到cos/本地 277 //根据项目上传标识区分上传到cos/本地
278 $projectModel = new Project(); 278 $projectModel = new Project();
279 - $project_info = $projectModel->read(['id'=>$this->cache['project_id']],['upload_location']);  
280 - $this->upload_location = $project_info['upload_location']; 279 + $project_info = $projectModel->read(['id' => $this->cache['project_id']], ['project_location']);
  280 + if ($project_info['project_location'] == 0) {//不为普通项目时 上传到本地服务器
  281 + $this->upload_location = 1;//1:上传到本地
  282 + }
281 } 283 }
282 $this->path = $this->uploads['path_b'].'/'.$this->cache['project_id'].'/'.$this->file_type[$this->param['refer']].'/'.date('Y-m'); 284 $this->path = $this->uploads['path_b'].'/'.$this->cache['project_id'].'/'.$this->file_type[$this->param['refer']].'/'.date('Y-m');
283 } 285 }
@@ -16,17 +16,6 @@ use Intervention\Image\Facades\Image; @@ -16,17 +16,6 @@ use Intervention\Image\Facades\Image;
16 16
17 class ImageController extends Controller 17 class ImageController extends Controller
18 { 18 {
19 - public $upload_img = [  
20 - //设置静态缓存参数(304)  
21 - 'header' => [  
22 - 'Cache-Control' => 'max-age=2592000',  
23 - 'Pragma' => 'cache',  
24 - 'Expires' => "%Expires%", // cache 1 month  
25 - 'etag' => "%etag%",  
26 - 'Last-Modified' => "%Last-Modified%",  
27 - 'Content-Description' => 'File Transfer',  
28 - ],  
29 - ];  
30 public $path = '';//路径 19 public $path = '';//路径
31 20
32 public $config = '';//存储默认配置 21 public $config = '';//存储默认配置
@@ -53,8 +42,6 @@ class ImageController extends Controller @@ -53,8 +42,6 @@ class ImageController extends Controller
53 public function __construct() 42 public function __construct()
54 { 43 {
55 $this->request = request(); 44 $this->request = request();
56 - $this->token = $this->request->header('token');  
57 - $this->cache = Cache::get($this->token);  
58 $this->param = $this->request->all(); 45 $this->param = $this->request->all();
59 $this->config = config('filesystems.disks.upload'); 46 $this->config = config('filesystems.disks.upload');
60 $this->uploads = config('upload.default_image'); 47 $this->uploads = config('upload.default_image');
@@ -79,34 +66,37 @@ class ImageController extends Controller @@ -79,34 +66,37 @@ class ImageController extends Controller
79 //查看缩略图是否存在 66 //查看缩略图是否存在
80 $filename = $this->config['root'] . '/' .$info['path'] . '_' . $w . '_' . $h; 67 $filename = $this->config['root'] . '/' .$info['path'] . '_' . $w . '_' . $h;
81 if(is_file($filename)){ 68 if(is_file($filename)){
82 - $last_modified_time = gmdate(time() + ((30 * 60 * 60 * 24))) . " GMT";  
83 - $header = str_replace(['%Expires%', "%etag%", '%Last-Modified%'],  
84 - [$last_modified_time, $hash . ':' . $w . '_' . $h . '_' . 1, $last_modified_time], $this->upload_img['header']);  
85 $content = file_get_contents($filename); 69 $content = file_get_contents($filename);
86 $header['Content-Length'] = strlen($content); 70 $header['Content-Length'] = strlen($content);
87 }else{ 71 }else{
88 - $path = $this->config['root'].'/'.$info['path'];  
89 - if (!is_file($path)) {  
90 - $this->response('指定图片已被系统删除!', Code::USER_ERROR);  
91 - }  
92 - $content = '';  
93 - $last_modified_time = gmdate(time() + ((30 * 60 * 60 * 24))) . " GMT";  
94 - $header = str_replace(['%Expires%', "%etag%", '%Last-Modified%'],  
95 - [$last_modified_time, $hash . ':' . $w . '_' . $h . '_' . 1, $last_modified_time], $this->upload_img['header']);  
96 - if ($w > 0 && $h > 0) {  
97 - $path = $this->cacheImage($info, $w, $h);  
98 - $content = file_get_contents($path);  
99 - $header['Content-Length'] = strlen($content);  
100 - } else {  
101 - $content = file_get_contents($path);  
102 - $header['Content-Length'] = strlen($content);  
103 - } 72 + $content = $this->readImageContent($info,$w,$h);
  73 + $header['Content-Length'] = strlen($content);
104 } 74 }
105 - $header['Content-Type'] = 'image/'.$info['type']; 75 + $header['Content-Type'] = $info['mime'];
106 return response($content,200,$header); 76 return response($content,200,$header);
107 } 77 }
108 78
109 - 79 + /**
  80 + * @remark :缩略图不存在时获取图片
  81 + * @name :readImageContent
  82 + * @author :lyh
  83 + * @method :post
  84 + * @time :2023/7/27 9:26
  85 + */
  86 + public function readImageContent($info,$w,$h)
  87 + {
  88 + $path = $this->config['root'] . '/' . $info['path'];
  89 + if (!is_file($path)) {
  90 + $this->response('指定图片已被系统删除!', Code::USER_ERROR);
  91 + }
  92 + if ($w > 0 && $h > 0) {
  93 + $path = $this->cacheImage($info, $w, $h);
  94 + $content = file_get_contents($path);
  95 + } else {
  96 + $content = file_get_contents($path);
  97 + }
  98 + return $content;
  99 + }
110 /** 100 /**
111 * @name :(图片上传)upload 101 * @name :(图片上传)upload
112 * @author :lyh 102 * @author :lyh
@@ -130,7 +120,8 @@ class ImageController extends Controller @@ -130,7 +120,8 @@ class ImageController extends Controller
130 }else{ 120 }else{
131 $size = $files->getSize(); 121 $size = $files->getSize();
132 $image_type = $files->getClientOriginalExtension(); 122 $image_type = $files->getClientOriginalExtension();
133 - return $this->single($files,$size,$image_type); 123 + $mime = $files->getMimeType();
  124 + return $this->single($files,$size,$image_type,$mime);
134 } 125 }
135 } 126 }
136 127
@@ -142,7 +133,7 @@ class ImageController extends Controller @@ -142,7 +133,7 @@ class ImageController extends Controller
142 * @method :post 133 * @method :post
143 * @time :2023/6/17 16:30 134 * @time :2023/6/17 16:30
144 */ 135 */
145 - public function single(&$files,$size,$image_type){ 136 + public function single(&$files,$size,$image_type,$mime){
146 $hash = hash_file('md5', $files->getPathname()); 137 $hash = hash_file('md5', $files->getPathname());
147 //查看文件是否存在 138 //查看文件是否存在
148 $imageModel = new ImageModel(); 139 $imageModel = new ImageModel();
@@ -162,7 +153,7 @@ class ImageController extends Controller @@ -162,7 +153,7 @@ class ImageController extends Controller
162 return $this->response($files->getError(), Code::USER_ERROR); 153 return $this->response($files->getError(), Code::USER_ERROR);
163 } 154 }
164 } 155 }
165 - $this->saveMysql($imageModel,$size,$image_type,$fileName,$hash,$this->upload_location); 156 + $this->saveMysql($imageModel,$size,$image_type,$fileName,$hash,$this->upload_location,$mime);
166 return $this->response('图片资源',Code::SUCCESS,$this->responseData($hash)); 157 return $this->response('图片资源',Code::SUCCESS,$this->responseData($hash));
167 } 158 }
168 159
@@ -173,7 +164,7 @@ class ImageController extends Controller @@ -173,7 +164,7 @@ class ImageController extends Controller
173 * @method :post 164 * @method :post
174 * @time :2023/7/19 16:38 165 * @time :2023/7/19 16:38
175 */ 166 */
176 - public function saveMysql(&$imageModel,$size,$image_type,$fileName,$hash,$is_cos = 0){ 167 + public function saveMysql(&$imageModel,$size,$image_type,$fileName,$hash,$is_cos = 0,$mime = ''){
177 $data = [ 168 $data = [
178 'path' => $this->path.'/'.$fileName, 169 'path' => $this->path.'/'.$fileName,
179 'created_at' => date('Y-m-d H:i:s',time()), 170 'created_at' => date('Y-m-d H:i:s',time()),
@@ -181,7 +172,8 @@ class ImageController extends Controller @@ -181,7 +172,8 @@ class ImageController extends Controller
181 'hash' => $hash, 172 'hash' => $hash,
182 'type'=>$image_type, 173 'type'=>$image_type,
183 'refer'=>$this->param['refer'] ?? 1, 174 'refer'=>$this->param['refer'] ?? 1,
184 - 'is_cos'=>$is_cos 175 + 'is_cos'=>$is_cos,
  176 + 'mime'=>$mime
185 ]; 177 ];
186 $rs = $imageModel->add($data); 178 $rs = $imageModel->add($data);
187 if ($rs === false) { 179 if ($rs === false) {
@@ -219,6 +211,7 @@ class ImageController extends Controller @@ -219,6 +211,7 @@ class ImageController extends Controller
219 foreach ($files as $file) { 211 foreach ($files as $file) {
220 $size = $file->getSize(); 212 $size = $file->getSize();
221 $image_type = $file->getClientOriginalExtension(); 213 $image_type = $file->getClientOriginalExtension();
  214 + $mime = $file->getMimeType();
222 $imageModel = new ImageModel(); 215 $imageModel = new ImageModel();
223 $hash = hash_file('md5', $file->getPathname()); 216 $hash = hash_file('md5', $file->getPathname());
224 $image_hash = $imageModel->read(['hash'=>$hash]); 217 $image_hash = $imageModel->read(['hash'=>$hash]);
@@ -239,7 +232,7 @@ class ImageController extends Controller @@ -239,7 +232,7 @@ class ImageController extends Controller
239 } 232 }
240 } 233 }
241 //批量存储 234 //批量存储
242 - $this->saveMysql($imageModel,$size,$image_type,$fileName,$hash,$this->upload_location); 235 + $this->saveMysql($imageModel,$size,$image_type,$fileName,$hash,$this->upload_location,$mime);
243 $data[] = $this->responseData($hash); 236 $data[] = $this->responseData($hash);
244 } 237 }
245 $this->response('图片资源',Code::SUCCESS,$data); 238 $this->response('图片资源',Code::SUCCESS,$data);
@@ -309,7 +302,7 @@ class ImageController extends Controller @@ -309,7 +302,7 @@ class ImageController extends Controller
309 $imageModel = new ImageModel(); 302 $imageModel = new ImageModel();
310 $lists = $imageModel->list($this->param,$order = 'id'); 303 $lists = $imageModel->list($this->param,$order = 'id');
311 foreach ($lists as $k => $v){ 304 foreach ($lists as $k => $v){
312 - $v['image_link'] = $this->getImageUrl($v['hash']); 305 + $v['image_link'] = getImageUrl($v['hash']);
313 $lists[$k] = $v; 306 $lists[$k] = $v;
314 } 307 }
315 $this->response('success',Code::SUCCESS,$lists); 308 $this->response('success',Code::SUCCESS,$lists);
@@ -328,39 +321,21 @@ class ImageController extends Controller @@ -328,39 +321,21 @@ class ImageController extends Controller
328 $this->path = $this->uploads['path_a'].'/'.$this->image_type[$this->param['refer']].'/'.date('Y-m'); 321 $this->path = $this->uploads['path_a'].'/'.$this->image_type[$this->param['refer']].'/'.date('Y-m');
329 }else{ 322 }else{
330 //B端上传 323 //B端上传
331 - if(isset($this->param['upload_method']) && $this->param['upload_method'] == 1){  
332 - //强制上传本地配置  
333 - $this->upload_location = 0;  
334 - }else{ 324 + $this->token = $this->request->header('token');
  325 + $this->cache = Cache::get($this->token);
  326 + if(!isset($this->param['upload_method'])){
335 //根据项目上传标识区分上传到cos/本地 327 //根据项目上传标识区分上传到cos/本地
336 $projectModel = new Project(); 328 $projectModel = new Project();
337 $project_info = $projectModel->read(['id'=>$this->cache['project_id']],['upload_location']); 329 $project_info = $projectModel->read(['id'=>$this->cache['project_id']],['upload_location']);
338 - $this->upload_location = $project_info['upload_location']; 330 + if ($project_info['project_location'] == 0) {//不为普通项目时 上传到本地服务器
  331 + $this->upload_location = 1;//上传到cos
  332 + }
339 } 333 }
340 $this->path = $this->uploads['path_b'].'/'.$this->cache['project_id'].'/'.$this->image_type[$this->param['refer']].'/'.date('Y-m'); 334 $this->path = $this->uploads['path_b'].'/'.$this->cache['project_id'].'/'.$this->image_type[$this->param['refer']].'/'.date('Y-m');
341 } 335 }
342 } 336 }
343 337
344 /** 338 /**
345 - * @remark :获取图片链接  
346 - * @name :getImageUrl  
347 - * @author :lyh  
348 - * @method :post  
349 - * @time :2023/7/20 16:46  
350 - */  
351 - public function getImageUrl($hash){  
352 - $imageModel = new ImageModel();  
353 - $info = $imageModel->read(['hash'=>$hash]);  
354 - if($info['is_cos'] == 1){  
355 - $cos = new CosService();  
356 - $url = $cos->getImageUrl($info['path']);  
357 - }else{  
358 - $url = url('a/image/'.$info['hash']);  
359 - }  
360 - return $url;  
361 - }  
362 -  
363 - /**  
364 * @remark :统一返回参数处理 339 * @remark :统一返回参数处理
365 * @name :responseData 340 * @name :responseData
366 * @author :lyh 341 * @author :lyh
@@ -370,7 +345,7 @@ class ImageController extends Controller @@ -370,7 +345,7 @@ class ImageController extends Controller
370 public function responseData($hash){ 345 public function responseData($hash){
371 $data = [ 346 $data = [
372 'image'=>$hash, 347 'image'=>$hash,
373 - 'image_link'=>$this->getImageUrl($hash), 348 + 'image_link'=>getImageUrl($hash),
374 'image_download'=>url('a/downLoad/images?hash='.$hash), 349 'image_download'=>url('a/downLoad/images?hash='.$hash),
375 ]; 350 ];
376 return $data; 351 return $data;
@@ -8,8 +8,6 @@ use App\Models\Manage\BelongingGroup; @@ -8,8 +8,6 @@ use App\Models\Manage\BelongingGroup;
8 use App\Models\Manage\EntryPosition; 8 use App\Models\Manage\EntryPosition;
9 use App\Models\Manage\JobLevel; 9 use App\Models\Manage\JobLevel;
10 use App\Models\Manage\ManageHr; 10 use App\Models\Manage\ManageHr;
11 -use Illuminate\Support\Facades\Log;  
12 -  
13 11
14 /** 12 /**
15 * Class ManageHrLogic 13 * Class ManageHrLogic
@@ -38,11 +36,9 @@ class HrLogic extends BaseLogic @@ -38,11 +36,9 @@ class HrLogic extends BaseLogic
38 } 36 }
39 37
40 public function save($param){ 38 public function save($param){
41 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export($param, true) . PHP_EOL, FILE_APPEND);  
42 foreach ($this->model::specieField() as $v){ 39 foreach ($this->model::specieField() as $v){
43 $param = $this->setJson($v,$param); 40 $param = $this->setJson($v,$param);
44 } 41 }
45 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export($param, true) . PHP_EOL, FILE_APPEND);  
46 return parent::save($param); 42 return parent::save($param);
47 } 43 }
48 44
@@ -154,7 +154,6 @@ class InquiryInfoLogic extends BaseLogic @@ -154,7 +154,6 @@ class InquiryInfoLogic extends BaseLogic
154 $arr_url = explode(',',$param['forward_url']); 154 $arr_url = explode(',',$param['forward_url']);
155 foreach ($arr_url as $v){ 155 foreach ($arr_url as $v){
156 $data['url'] = $v; 156 $data['url'] = $v;
157 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export(json_encode($data).'debug---------------33333333333', true) . PHP_EOL, FILE_APPEND);  
158 $this->inquiryForward($data); 157 $this->inquiryForward($data);
159 } 158 }
160 //更新数据库,修改状态为已转发 159 //更新数据库,修改状态为已转发
@@ -102,7 +102,7 @@ class BTemplateLogic extends BaseLogic @@ -102,7 +102,7 @@ class BTemplateLogic extends BaseLogic
102 $ATemplateModel = new Template(); 102 $ATemplateModel = new Template();
103 $ATemplateInfo = $ATemplateModel->read(['id'=>$info['template_id']]); 103 $ATemplateInfo = $ATemplateModel->read(['id'=>$info['template_id']]);
104 $TemplateInfo['name'] = $ATemplateInfo['name']; 104 $TemplateInfo['name'] = $ATemplateInfo['name'];
105 - $TemplateInfo['image_link'] = $this->getImageUrl($ATemplateInfo['image']); 105 + $TemplateInfo['image_link'] = getImageUrl($ATemplateInfo['image']);
106 } 106 }
107 $TemplateInfo['html'] = $this->getHeadFooter($TemplateInfo['html']); 107 $TemplateInfo['html'] = $this->getHeadFooter($TemplateInfo['html']);
108 return $this->success($TemplateInfo); 108 return $this->success($TemplateInfo);
@@ -125,7 +125,7 @@ class BTemplateLogic extends BaseLogic @@ -125,7 +125,7 @@ class BTemplateLogic extends BaseLogic
125 $this->fail('请先装修首页'); 125 $this->fail('请先装修首页');
126 } 126 }
127 $html = preg_replace('/<style id="vvvebjs-styles">(.*?)<\/style>/s', "<style id='vvvebjs-styles'></style>", $homeTemplateInfo['html']); 127 $html = preg_replace('/<style id="vvvebjs-styles">(.*?)<\/style>/s', "<style id='vvvebjs-styles'></style>", $homeTemplateInfo['html']);
128 - $html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', "<main></main>", $html); 128 + $html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', "<main>{$this->getProductModule()}</main>", $html);
129 }else{ 129 }else{
130 $homeTemplateInfo = $this->webTemplateInfo($info['template_id'],1,0); 130 $homeTemplateInfo = $this->webTemplateInfo($info['template_id'],1,0);
131 if($homeTemplateInfo === false){ 131 if($homeTemplateInfo === false){
@@ -338,4 +338,18 @@ class BTemplateLogic extends BaseLogic @@ -338,4 +338,18 @@ class BTemplateLogic extends BaseLogic
338 //返回 338 //返回
339 return $this->success($data); 339 return $this->success($data);
340 } 340 }
  341 +
  342 + /**
  343 + * @remark :默认产品模块
  344 + * @name :getProductModule
  345 + * @author :lyh
  346 + * @method :post
  347 + * @time :2023/7/27 15:08
  348 + */
  349 + public function getProductModule(){
  350 + //获取公共主题头部底部
  351 + $serviceSettingModel = new ServiceSettingModel();
  352 + $info = $serviceSettingModel->read(['type'=>3]);
  353 + return $info['values'];
  354 + }
341 } 355 }
@@ -33,7 +33,7 @@ class CategoryLogic extends BaseLogic @@ -33,7 +33,7 @@ class CategoryLogic extends BaseLogic
33 foreach ($data as &$v){ 33 foreach ($data as &$v){
34 $v['url'] = $this->getProjectDomain() . $v['route'] ; 34 $v['url'] = $this->getProjectDomain() . $v['route'] ;
35 $v['product_num'] = $this->getProductNum($v['id']); 35 $v['product_num'] = $this->getProductNum($v['id']);
36 - $v['image_link'] = $this->getImageUrl($v['image']); 36 + $v['image_link'] = getImageUrl($v['image']);
37 } 37 }
38 if(!$map){ 38 if(!$map){
39 $data = Arr::listToTree($data); 39 $data = Arr::listToTree($data);
@@ -45,7 +45,7 @@ class CategoryLogic extends BaseLogic @@ -45,7 +45,7 @@ class CategoryLogic extends BaseLogic
45 { 45 {
46 $info = $this->model->read(['id'=>$id]); 46 $info = $this->model->read(['id'=>$id]);
47 $info['url'] = $this->getProjectDomain() . $info['route'] ; 47 $info['url'] = $this->getProjectDomain() . $info['route'] ;
48 - $info['image_link'] = $this->getImageUrl($info['image']); 48 + $info['image_link'] = getImageUrl($info['image']);
49 return $this->success($info); 49 return $this->success($info);
50 } 50 }
51 51
@@ -31,7 +31,7 @@ class ProductLogic extends BaseLogic @@ -31,7 +31,7 @@ class ProductLogic extends BaseLogic
31 $data = parent::getList($map, $sort, $columns, $limit); 31 $data = parent::getList($map, $sort, $columns, $limit);
32 foreach ($data['list'] as &$v){ 32 foreach ($data['list'] as &$v){
33 $v = $this->formatData($v); 33 $v = $this->formatData($v);
34 - $v['thumb']['image_link'] = $this->getImageUrl($v['thumb']['url']);//图片统一 34 + $v['thumb']['image_link'] = getImageUrl($v['thumb']['url']);//图片统一
35 } 35 }
36 return $this->success($data); 36 return $this->success($data);
37 } 37 }
@@ -43,11 +43,11 @@ class ProductLogic extends BaseLogic @@ -43,11 +43,11 @@ class ProductLogic extends BaseLogic
43 //统一图片链接 43 //统一图片链接
44 if(!empty($info['gallery'])){ 44 if(!empty($info['gallery'])){
45 foreach ($info['gallery'] as $k => $v){ 45 foreach ($info['gallery'] as $k => $v){
46 - $v['image_link'] = $this->getImageUrl($v['url']); 46 + $v['image_link'] = getImageUrl($v['url']);
47 $info['gallery'][$k] = $v; 47 $info['gallery'][$k] = $v;
48 } 48 }
49 } 49 }
50 - $info['icon_link'] = $this->getImageUrl($info['icon']); 50 + $info['icon_link'] = getImageUrl($info['icon']);
51 return $this->success($info); 51 return $this->success($info);
52 } 52 }
53 53
@@ -58,6 +58,7 @@ class ProductLogic extends BaseLogic @@ -58,6 +58,7 @@ class ProductLogic extends BaseLogic
58 foreach ($info['keyword_id'] as $keyword_id){ 58 foreach ($info['keyword_id'] as $keyword_id){
59 $info['keyword_id_text'][] =(new KeywordLogic())->getCacheInfo($keyword_id)['title']??''; 59 $info['keyword_id_text'][] =(new KeywordLogic())->getCacheInfo($keyword_id)['title']??'';
60 } 60 }
  61 + $info['product_type_text'] = $this->model->productType[$info['product_type']];
61 $info['category_id_text'] = Arr::arrToSet($info['category_id_text'], 'trim'); 62 $info['category_id_text'] = Arr::arrToSet($info['category_id_text'], 'trim');
62 $info['keyword_id_text'] = Arr::arrToSet($info['keyword_id_text'], 'trim'); 63 $info['keyword_id_text'] = Arr::arrToSet($info['keyword_id_text'], 'trim');
63 $info['status_text'] = Product::statusMap()[$info['status']] ?? ''; 64 $info['status_text'] = Product::statusMap()[$info['status']] ?? '';
@@ -383,34 +383,6 @@ class Logic @@ -383,34 +383,6 @@ class Logic
383 } 383 }
384 384
385 /** 385 /**
386 - * @remark :获取图片链接  
387 - * @name :getImageUrl  
388 - * @author :lyh  
389 - * @method :post  
390 - * @time :2023/7/20 16:46  
391 - */  
392 - public function getImageUrl($hash){  
393 -  
394 - if(is_array($hash)){  
395 - $url = [];  
396 - foreach ($hash as $k => $v){  
397 - $url[$k] = $this->getImageUrl($v);  
398 - }  
399 - }else{  
400 - $imageModel = new Image();  
401 - $info = $imageModel->read(['hash'=>$hash]);  
402 - if($info['is_cos'] == 1){  
403 - $cos = new CosService();  
404 - $url = $cos->getImageUrl($info['path']);  
405 - }else{  
406 - $url = url('a/image/'.$info['hash']);  
407 - }  
408 - }  
409 -  
410 - return $url;  
411 - }  
412 -  
413 - /**  
414 * 获取实例 386 * 获取实例
415 * @param mixed ...$params 387 * @param mixed ...$params
416 * @return static 388 * @return static
@@ -32,6 +32,15 @@ class Product extends Base @@ -32,6 +32,15 @@ class Product extends Base
32 ]; 32 ];
33 } 33 }
34 34
  35 + /**
  36 + * @var 获取产品类型
  37 + */
  38 + public $productType = [
  39 + 1=>'一般产品',
  40 + 2=>'推荐产品',
  41 + 3=>'热销产品'
  42 + ];
  43 +
35 public function setThumbAttribute($value){ 44 public function setThumbAttribute($value){
36 $this->attributes['thumb'] = Arr::a2s($value); 45 $this->attributes['thumb'] = Arr::a2s($value);
37 } 46 }
@@ -4,7 +4,7 @@ namespace App\Services; @@ -4,7 +4,7 @@ namespace App\Services;
4 4
5 use Qcloud\Cos\Client; 5 use Qcloud\Cos\Client;
6 /** 6 /**
7 - * @remark : 7 + * @remark :对象存储cos
8 * @class :CosService.php 8 * @class :CosService.php
9 * @author :lyh 9 * @author :lyh
10 * @time :2023/7/19 15:09 10 * @time :2023/7/19 15:09
@@ -60,5 +60,5 @@ class CosService @@ -60,5 +60,5 @@ class CosService
60 $imageUrl = $cosClient->getObjectUrl($cos['bucket'], trim($image_name,'/'), '+10 years'); 60 $imageUrl = $cosClient->getObjectUrl($cos['bucket'], trim($image_name,'/'), '+10 years');
61 return $imageUrl; 61 return $imageUrl;
62 } 62 }
63 - 63 +
64 } 64 }