Merge remote-tracking branch 'origin/master' into akun
正在显示
10 个修改的文件
包含
232 行增加
和
22 行删除
| @@ -58,9 +58,31 @@ class lyhDemo extends Command | @@ -58,9 +58,31 @@ class lyhDemo extends Command | ||
| 58 | protected $description = '更新路由'; | 58 | protected $description = '更新路由'; |
| 59 | 59 | ||
| 60 | public function handle(){ | 60 | public function handle(){ |
| 61 | - return $this->_actionRoute(); | 61 | + return $this->_actionAiBolog(); |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | + /** | ||
| 65 | + * @remark :修改ai_blog | ||
| 66 | + * @name :_actionAiBolog | ||
| 67 | + * @author :lyh | ||
| 68 | + * @method :post | ||
| 69 | + * @time :2025/11/21 13:52 | ||
| 70 | + */ | ||
| 71 | + public function _actionAiBolog() | ||
| 72 | + { | ||
| 73 | + $projectModel = new Project(); | ||
| 74 | + $lists = $projectModel->list(['delete_status' => 0,'id'=>1,'project_type'=>0,'extend_type'=>0,'type'=>['in',[1,2,3,4,6]]], 'id', ['id']); | ||
| 75 | + foreach ($lists as $item) { | ||
| 76 | + echo date('Y-m-d H:i:s') . '开始--项目的id:' . $item['id'] . PHP_EOL; | ||
| 77 | + ProjectServer::useProject($item['project_id']); | ||
| 78 | + $aiblog = new AiBlog(); | ||
| 79 | + $task_ids = $aiblog->selectField(['image'=>'','created_at'=>['>=','2025-11-17 00:00:00']],'691b5b8a9632e'); | ||
| 80 | + dd($task_ids); | ||
| 81 | + DB::disconnect('custom_mysql'); | ||
| 82 | + } | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + | ||
| 64 | public function _actionDa() | 86 | public function _actionDa() |
| 65 | { | 87 | { |
| 66 | $geoLinkModel = new GeoLink(); | 88 | $geoLinkModel = new GeoLink(); |
| @@ -1642,5 +1642,16 @@ if (!function_exists('httpGetSsl')) { | @@ -1642,5 +1642,16 @@ if (!function_exists('httpGetSsl')) { | ||
| 1642 | return $truncated; | 1642 | return $truncated; |
| 1643 | } | 1643 | } |
| 1644 | 1644 | ||
| 1645 | - | 1645 | + /** |
| 1646 | + * @remark :写入日志 | ||
| 1647 | + * @name :outMessage | ||
| 1648 | + * @author :lyh | ||
| 1649 | + * @method :post | ||
| 1650 | + * @time :2025/11/20 16:04 | ||
| 1651 | + */ | ||
| 1652 | + function outMessage($filename = 'lyh_info',$message = '') | ||
| 1653 | + { | ||
| 1654 | + @file_put_contents(storage_path('logs/'.$filename.'.log'), "错误信息: " . $message . PHP_EOL, FILE_APPEND); | ||
| 1655 | + return true; | ||
| 1656 | + } | ||
| 1646 | } | 1657 | } |
| @@ -8,9 +8,12 @@ | @@ -8,9 +8,12 @@ | ||
| 8 | namespace App\Http\Controllers\Api; | 8 | namespace App\Http\Controllers\Api; |
| 9 | 9 | ||
| 10 | use App\Enums\Common\Code; | 10 | use App\Enums\Common\Code; |
| 11 | +use App\Models\Geo\GeoConf; | ||
| 11 | use App\Models\Geo\GeoConfirm; | 12 | use App\Models\Geo\GeoConfirm; |
| 12 | use App\Models\Geo\GeoWritings; | 13 | use App\Models\Geo\GeoWritings; |
| 14 | +use App\Models\Manage\ManageHr; | ||
| 13 | use App\Models\Project\Project; | 15 | use App\Models\Project\Project; |
| 16 | +use App\Services\DingService; | ||
| 14 | use Illuminate\Http\Request; | 17 | use Illuminate\Http\Request; |
| 15 | use Illuminate\Support\Facades\Crypt; | 18 | use Illuminate\Support\Facades\Crypt; |
| 16 | 19 | ||
| @@ -89,11 +92,28 @@ class GeoController extends BaseController | @@ -89,11 +92,28 @@ class GeoController extends BaseController | ||
| 89 | if ($info['status'] == GeoWritings::STATUS_FINISH){ | 92 | if ($info['status'] == GeoWritings::STATUS_FINISH){ |
| 90 | return $this->response('当前文章已确认,不可再次确认',Code::SYSTEM_ERROR); | 93 | return $this->response('当前文章已确认,不可再次确认',Code::SYSTEM_ERROR); |
| 91 | } | 94 | } |
| 95 | + try { | ||
| 92 | $this->param['confirm_ip'] = $this->request->ip(); | 96 | $this->param['confirm_ip'] = $this->request->ip(); |
| 93 | $this->param['confirm_at'] = date('Y-m-d H:i:s'); | 97 | $this->param['confirm_at'] = date('Y-m-d H:i:s'); |
| 94 | $this->param['content_length'] = strlen($this->param['content']); | 98 | $this->param['content_length'] = strlen($this->param['content']); |
| 95 | $this->param['status'] = GeoWritings::STATUS_FINISH; | 99 | $this->param['status'] = GeoWritings::STATUS_FINISH; |
| 96 | $geoWritingsModel->edit($this->param,['uniqid' => $token]); | 100 | $geoWritingsModel->edit($this->param,['uniqid' => $token]); |
| 101 | + $geoConfModel = new GeoConf(); | ||
| 102 | + $confInfo = $geoConfModel->read(['project_id'=>$info['project_id']]); | ||
| 103 | + $hrModel = new ManageHr(); | ||
| 104 | + $manage_name = $hrModel->getName($confInfo['manager_id'] ??''); | ||
| 105 | + $dingService = new DingService(); | ||
| 106 | + $dingService->handle([ | ||
| 107 | + 'keyword' => '项目数据确认', | ||
| 108 | + 'msg' => | ||
| 109 | + 'cm:文章确认完成' . PHP_EOL . | ||
| 110 | + '项目名称:'.$confInfo['company'] ?? '' . PHP_EOL . | ||
| 111 | + '负责人:'.$manage_name . PHP_EOL, | ||
| 112 | + 'isAtAll' => false, // 是否@所有人 | ||
| 113 | + ], 'https://oapi.dingtalk.com/robot/send?access_token=4effe85882009a8a1617dbeadc38c350f832deef7431ce10f5fda751b4c82fb9'); | ||
| 114 | + }catch (\Exception $e){ | ||
| 115 | + $this->response('非法请求',Code::SYSTEM_ERROR); | ||
| 116 | + } | ||
| 97 | $this->response('success',Code::SUCCESS); | 117 | $this->response('success',Code::SUCCESS); |
| 98 | } | 118 | } |
| 99 | 119 | ||
| @@ -138,10 +158,31 @@ class GeoController extends BaseController | @@ -138,10 +158,31 @@ class GeoController extends BaseController | ||
| 138 | 'confirm_num.max' => '客户确认数量不能为空', | 158 | 'confirm_num.max' => '客户确认数量不能为空', |
| 139 | ]); | 159 | ]); |
| 140 | $geoConfirmModel = new GeoConfirm(); | 160 | $geoConfirmModel = new GeoConfirm(); |
| 161 | + $info = $geoConfirmModel->read(['uniqid'=>$this->param['uniqid']]); | ||
| 162 | + if ($info === false){ | ||
| 163 | + $this->response('当前数据不存在已被删除',Code::SYSTEM_ERROR); | ||
| 164 | + } | ||
| 165 | + try { | ||
| 141 | $this->param['status'] = $geoConfirmModel::STATUS_FINISH; | 166 | $this->param['status'] = $geoConfirmModel::STATUS_FINISH; |
| 142 | $this->param['confirm_ip'] = $this->request->ip(); | 167 | $this->param['confirm_ip'] = $this->request->ip(); |
| 143 | $this->param['confirm_at'] = date('Y-m-d H:i:s'); | 168 | $this->param['confirm_at'] = date('Y-m-d H:i:s'); |
| 144 | - $result = $geoConfirmModel->edit($this->param,['uniqid'=>$this->param['uniqid']]); | 169 | + $result = $geoConfirmModel->edit($this->param,['id'=>$info['$info']]); |
| 170 | + $geoConfModel = new GeoConf(); | ||
| 171 | + $confInfo = $geoConfModel->read(['project_id'=>$info['project_id']]); | ||
| 172 | + $hrModel = new ManageHr(); | ||
| 173 | + $manage_name = $hrModel->getName($confInfo['manager_id'] ??''); | ||
| 174 | + $dingService = new DingService(); | ||
| 175 | + $dingService->handle([ | ||
| 176 | + 'keyword' => '项目数据确认', | ||
| 177 | + 'msg' => | ||
| 178 | + 'cm:'.(($info['type'] == 1) ? '标题确认' : '关键词确认'). PHP_EOL . | ||
| 179 | + '项目名称:'.$confInfo['company'] ?? '' . PHP_EOL . | ||
| 180 | + '负责人:'.$manage_name . PHP_EOL, | ||
| 181 | + 'isAtAll' => false, // 是否@所有人 | ||
| 182 | + ], 'https://oapi.dingtalk.com/robot/send?access_token=4effe85882009a8a1617dbeadc38c350f832deef7431ce10f5fda751b4c82fb9'); | ||
| 183 | + }catch (\Exception $e){ | ||
| 184 | + $this->response('非法请求',Code::SYSTEM_ERROR); | ||
| 185 | + } | ||
| 145 | $this->response('success',Code::SUCCESS,$result); | 186 | $this->response('success',Code::SUCCESS,$result); |
| 146 | } | 187 | } |
| 147 | } | 188 | } |
| @@ -231,11 +231,22 @@ class IndexController extends BaseController | @@ -231,11 +231,22 @@ class IndexController extends BaseController | ||
| 231 | */ | 231 | */ |
| 232 | public function prInfoDownload() | 232 | public function prInfoDownload() |
| 233 | { | 233 | { |
| 234 | - $url = 'http://crawl.scraper.waimaoq.com/export/issuewire?token=MT0CM7y4tdFTFTm'; | ||
| 235 | - $response = Http::get($url); | 234 | + $url = 'http://crawl.scraper.waimaoq.com/export/issuewire'; |
| 235 | + $param = [ | ||
| 236 | + 'page' => $this->page, | ||
| 237 | + 'page_size' => $this->row, | ||
| 238 | + 'token' => 'MT0CM7y4tdFTFTm', | ||
| 239 | + 'pr_id' => $this->param['pr_id'] ?? '', | ||
| 240 | + 'release_time_start'=>$this->param['release_time_start'] ?? '', | ||
| 241 | + 'release_time_end'=>$this->param['release_time_end'] ?? '', | ||
| 242 | + ]; | ||
| 243 | + $param = array_filter($param); | ||
| 244 | + $response = Http::withHeaders(['Accept' => 'application/json',])->get($url, $param); | ||
| 236 | if ($response->successful()) { | 245 | if ($response->successful()) { |
| 237 | $result = $response->json(); | 246 | $result = $response->json(); |
| 247 | + $this->response('success', Code::SUCCESS, ['url' => $url, 'list' => $result, 'page' => $this->page, 'page_size' => $this->row]); | ||
| 248 | + } else { | ||
| 249 | + $this->response('请求失败', Code::SYSTEM_ERROR, ['status_code' => $response->status(), 'error' => $response->body()]); | ||
| 238 | } | 250 | } |
| 239 | - $this->response('success', Code::SUCCESS, ['url'=>$url,'list'=>$result ?? []]); | ||
| 240 | } | 251 | } |
| 241 | } | 252 | } |
| @@ -375,6 +375,8 @@ class AsideTicketController extends BaseController | @@ -375,6 +375,8 @@ class AsideTicketController extends BaseController | ||
| 375 | } | 375 | } |
| 376 | if ($project->wechat_switch) | 376 | if ($project->wechat_switch) |
| 377 | $project->pushWechatGroupMsg(); | 377 | $project->pushWechatGroupMsg(); |
| 378 | + else | ||
| 379 | + $this->response('请先点击开关,打开微信推送', Code::USER_MODEL_NOTFOUND_ERROE); | ||
| 378 | $this->response('success', Code::SUCCESS); | 380 | $this->response('success', Code::SUCCESS); |
| 379 | } | 381 | } |
| 380 | } | 382 | } |
| @@ -9,17 +9,101 @@ | @@ -9,17 +9,101 @@ | ||
| 9 | 9 | ||
| 10 | namespace App\Http\Controllers\Bside\ExtensionModule; | 10 | namespace App\Http\Controllers\Bside\ExtensionModule; |
| 11 | 11 | ||
| 12 | +use App\Enums\Common\Code; | ||
| 12 | use App\Http\Controllers\Bside\BaseController; | 13 | use App\Http\Controllers\Bside\BaseController; |
| 13 | -use App\Models\ExtentModule\ExtensionModuleField; | ||
| 14 | use App\Models\ExtentModule\ExtensionModuleValue; | 14 | use App\Models\ExtentModule\ExtensionModuleValue; |
| 15 | -use Illuminate\Http\Request; | 15 | +use Illuminate\Support\Facades\Cache; |
| 16 | 16 | ||
| 17 | class Extension3915ModuleController extends BaseController | 17 | class Extension3915ModuleController extends BaseController |
| 18 | { | 18 | { |
| 19 | - public function __construct(Request $request) | 19 | + |
| 20 | + /** | ||
| 21 | + * @remark :获取列表数据 | ||
| 22 | + * @name :lists | ||
| 23 | + * @author :lyh | ||
| 24 | + * @method :post | ||
| 25 | + * @time :2025/11/20 14:38 | ||
| 26 | + */ | ||
| 27 | + public function lists(){ | ||
| 28 | + $this->request->validate([ | ||
| 29 | + 'module_id'=>'required', | ||
| 30 | + ],[ | ||
| 31 | + 'module_id.required' => '模块id不能为空', | ||
| 32 | + ]); | ||
| 33 | + $searchParam = [ | ||
| 34 | + 'module_id'=>$this->param['module_id'], | ||
| 35 | + ]; | ||
| 36 | + $resultData = Cache::get('extension_module_list_3915_'.$this->param['module_id']); | ||
| 37 | + if(empty($resultData)){ | ||
| 38 | + $data = []; | ||
| 39 | + $moduleValueModel = new ExtensionModuleValue(); | ||
| 40 | + if(isset($this->param['field_id']) && ($this->param['field_id'] != 0) && isset($this->param['value'])){ | ||
| 41 | + $uuidArr = $moduleValueModel->formatQuery(['field_id'=>$this->param['field_id'],'value'=>$this->param['value'],'module_id'=>$this->param['module_id']])->distinct()->pluck('uuid')->toArray(); | ||
| 42 | + if(!empty($uuidArr)){ | ||
| 43 | + $searchParam['uuid'] = ['in',$uuidArr]; | ||
| 44 | + } | ||
| 45 | + } | ||
| 46 | + if(isset($this->param['start_time']) && !empty($this->param['start_time']) && isset($this->param['end_time']) && !empty($this->param['end_time'])){ | ||
| 47 | + $searchParam['created_at'] = ['between',[$this->param['start_time'],$this->param['end_time']]]; | ||
| 48 | + } | ||
| 49 | + $lists = $moduleValueModel->list($searchParam); | ||
| 50 | + if(!empty($lists)){ | ||
| 51 | + foreach ($lists as $k => $v){ | ||
| 52 | + $data[$v['uuid']][$v['field_id']] = $v['value']; | ||
| 53 | + $data[$v['uuid']]['created_at'] = $v['created_at']; | ||
| 54 | + } | ||
| 55 | + } | ||
| 56 | + $resultData = []; | ||
| 57 | + foreach ($data as $k => $v){ | ||
| 58 | + $v['uuid'] = $k; | ||
| 59 | + $resultData[] = $v; | ||
| 60 | + } | ||
| 61 | + Cache::add('extension_module_list_3915_'.$this->param['module_id'],$resultData); | ||
| 62 | + } | ||
| 63 | + $resultData = $this->formatPaginate($resultData,$this->row,$this->page); | ||
| 64 | + //执行分页 | ||
| 65 | + $this->response('success',Code::SUCCESS,$resultData); | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + /** | ||
| 69 | + * @remark :分页 | ||
| 70 | + * @name :simplePaginate | ||
| 71 | + * @author :lyh | ||
| 72 | + * @method :post | ||
| 73 | + * @time :2025/11/20 14:50 | ||
| 74 | + */ | ||
| 75 | + public function formatPaginate($data, $size = 20, $page = 1) | ||
| 76 | + { | ||
| 77 | + $collection = collect($data); | ||
| 78 | + $total = $collection->count(); | ||
| 79 | + $totalPage = max(1, ceil($total / $size)); | ||
| 80 | + // 确保页码在有效范围内 | ||
| 81 | + $page = max(1, min($page, $totalPage)); | ||
| 82 | + $list = $collection->forPage($page, $size)->values()->toArray(); | ||
| 83 | + return [ | ||
| 84 | + 'list' => $list, | ||
| 85 | + 'page' => (int)$page, | ||
| 86 | + 'size' => (string)$size, | ||
| 87 | + 'total' => $total, | ||
| 88 | + 'total_page' => $totalPage | ||
| 89 | + ]; | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + /** | ||
| 93 | + * @remark :导入数据 | ||
| 94 | + * @name :importData | ||
| 95 | + * @author :lyh | ||
| 96 | + * @method :post | ||
| 97 | + * @time :2025/11/20 14:40 | ||
| 98 | + */ | ||
| 99 | + public function importData() | ||
| 20 | { | 100 | { |
| 21 | - Parent::__construct($request); | ||
| 22 | - $this->valueModel = new ExtensionModuleValue(); | ||
| 23 | - $this->filedModel = new ExtensionModuleField(); | 101 | + $data = $this->param; |
| 102 | + //todo::优先截断表 | ||
| 103 | + $resultData = []; | ||
| 104 | + foreach ($data as $k => $v){ | ||
| 105 | + | ||
| 106 | + } | ||
| 107 | + return $data; | ||
| 24 | } | 108 | } |
| 25 | } | 109 | } |
| @@ -207,11 +207,14 @@ class ImageController extends Controller | @@ -207,11 +207,14 @@ class ImageController extends Controller | ||
| 207 | if($this->upload_location == 0){ | 207 | if($this->upload_location == 0){ |
| 208 | $watermarkOptions = $this->getProjectConfig($this->cache['project_id'] ?? 0); | 208 | $watermarkOptions = $this->getProjectConfig($this->cache['project_id'] ?? 0); |
| 209 | $cosService = new CosService(); | 209 | $cosService = new CosService(); |
| 210 | - $cosService->uploadFile($files,$this->path,$fileName,false,$watermarkOptions); | 210 | + $res = $cosService->uploadFile($files,$this->path,$fileName,false,$watermarkOptions); |
| 211 | }else{ | 211 | }else{ |
| 212 | //TODO::上传亚马逊 | 212 | //TODO::上传亚马逊 |
| 213 | $amazonS3Service = new AmazonS3Service(); | 213 | $amazonS3Service = new AmazonS3Service(); |
| 214 | - $amazonS3Service->uploadFiles($files,$this->path,$fileName); | 214 | + $res = $amazonS3Service->uploadFiles($files,$this->path,$fileName); |
| 215 | + } | ||
| 216 | + if($res === false){ | ||
| 217 | + $this->response('上传失败,请重新上传',Code::SYSTEM_ERROR); | ||
| 215 | } | 218 | } |
| 216 | $this->saveMysql($imageModel,$files->getSize(),$image_type,$fileName,$hash,$this->upload_location,$files->getMimeType(), $name); | 219 | $this->saveMysql($imageModel,$files->getSize(),$image_type,$fileName,$hash,$this->upload_location,$files->getMimeType(), $name); |
| 217 | $this->synchronizationImage($fileName,$this->upload_location); | 220 | $this->synchronizationImage($fileName,$this->upload_location); |
| @@ -354,11 +357,15 @@ class ImageController extends Controller | @@ -354,11 +357,15 @@ class ImageController extends Controller | ||
| 354 | if($this->upload_location == 0){ | 357 | if($this->upload_location == 0){ |
| 355 | $watermarkOptions = $this->getProjectConfig($this->cache['project_id'] ?? 0); | 358 | $watermarkOptions = $this->getProjectConfig($this->cache['project_id'] ?? 0); |
| 356 | $cosService = new CosService(); | 359 | $cosService = new CosService(); |
| 357 | - $cosService->uploadFile($file,$this->path,$fileName,false,$watermarkOptions); | 360 | + $res = $cosService->uploadFile($file,$this->path,$fileName,false,$watermarkOptions); |
| 358 | }else{ | 361 | }else{ |
| 359 | //TODO::上传亚马逊 | 362 | //TODO::上传亚马逊 |
| 360 | $amazonS3Service = new AmazonS3Service(); | 363 | $amazonS3Service = new AmazonS3Service(); |
| 361 | - $amazonS3Service->uploadFiles($file,$this->path,$fileName); | 364 | + $res = $amazonS3Service->uploadFiles($file,$this->path,$fileName); |
| 365 | + } | ||
| 366 | + if($res === false){ | ||
| 367 | + outMessage('upload_images','图片上传失败'.$name); | ||
| 368 | + continue; | ||
| 362 | } | 369 | } |
| 363 | $this->synchronizationImage($fileName,$this->upload_location); | 370 | $this->synchronizationImage($fileName,$this->upload_location); |
| 364 | $data[] = $this->responseData($this->path.'/'.$fileName,$name); | 371 | $data[] = $this->responseData($this->path.'/'.$fileName,$name); |
| @@ -700,6 +707,9 @@ class ImageController extends Controller | @@ -700,6 +707,9 @@ class ImageController extends Controller | ||
| 700 | $info = $imageSetting->read(['project_id'=>$this->cache['project_id']]); | 707 | $info = $imageSetting->read(['project_id'=>$this->cache['project_id']]); |
| 701 | $domain = 'http://globalso-v6-1309677403.cos.ap-hongkong.myqcloud.com';//cos域名 | 708 | $domain = 'http://globalso-v6-1309677403.cos.ap-hongkong.myqcloud.com';//cos域名 |
| 702 | if($is_image){ | 709 | if($is_image){ |
| 710 | + if(empty($data['image'])){ | ||
| 711 | + $this->response('开启图片水印需要先关闭水印功能,重新上传水印图片'.Code::SYSTEM_ERROR); | ||
| 712 | + } | ||
| 703 | $param = [ | 713 | $param = [ |
| 704 | 'image/'.$domain.($data['image'] ?? ''),//图片 | 714 | 'image/'.$domain.($data['image'] ?? ''),//图片 |
| 705 | 'gravity/'.($data['gravity'] ?? 'SouthEast'), | 715 | 'gravity/'.($data['gravity'] ?? 'SouthEast'), |
| @@ -92,12 +92,15 @@ class GeoArticleLogic extends BaseLogic | @@ -92,12 +92,15 @@ class GeoArticleLogic extends BaseLogic | ||
| 92 | if(!empty($this->param['data'])){ | 92 | if(!empty($this->param['data'])){ |
| 93 | $data = []; | 93 | $data = []; |
| 94 | foreach ($this->param['data'] as $item){ | 94 | foreach ($this->param['data'] as $item){ |
| 95 | + $info = $this->model->read(['url'=>$item['url'],'filename'=>$item['filename']],['id','url']); | ||
| 96 | + if($info === false){ | ||
| 95 | $data[] = [ | 97 | $data[] = [ |
| 96 | 'filename' => $item['filename'], | 98 | 'filename' => $item['filename'], |
| 97 | 'url'=> $item['url'], | 99 | 'url'=> $item['url'], |
| 98 | 'project_id'=>$this->param['project_id'] | 100 | 'project_id'=>$this->param['project_id'] |
| 99 | ]; | 101 | ]; |
| 100 | } | 102 | } |
| 103 | + } | ||
| 101 | $this->model->insertAll($data); | 104 | $this->model->insertAll($data); |
| 102 | } | 105 | } |
| 103 | }catch (\Exception $e){ | 106 | }catch (\Exception $e){ |
| @@ -41,6 +41,7 @@ class APublicModel extends Base | @@ -41,6 +41,7 @@ class APublicModel extends Base | ||
| 41 | ->where('project_id', $project_id)->where('status', self::STATUS_ON)->count(); | 41 | ->where('project_id', $project_id)->where('status', self::STATUS_ON)->count(); |
| 42 | $newsNumber = DB::connection('custom_mysql')->table('gl_news') | 42 | $newsNumber = DB::connection('custom_mysql')->table('gl_news') |
| 43 | ->where('project_id', $project_id)->where('status', self::STATUS_ON)->count(); | 43 | ->where('project_id', $project_id)->where('status', self::STATUS_ON)->count(); |
| 44 | + $aiBlogNumber = DB::connection('custom_mysql')->table('gl_ai_blog')->where('project_id', $project_id)->count(); | ||
| 44 | $keyNumber = DB::connection('custom_mysql')->table('gl_product_keyword') | 45 | $keyNumber = DB::connection('custom_mysql')->table('gl_product_keyword') |
| 45 | ->where('project_id', $project_id)->where('status', self::STATUS_ON)->count(); | 46 | ->where('project_id', $project_id)->where('status', self::STATUS_ON)->count(); |
| 46 | //获取项目的询盘数量 | 47 | //获取项目的询盘数量 |
| @@ -49,7 +50,7 @@ class APublicModel extends Base | @@ -49,7 +50,7 @@ class APublicModel extends Base | ||
| 49 | if(!empty($countInfo)){ | 50 | if(!empty($countInfo)){ |
| 50 | $inquiryNumber = $countInfo->inquiry_num ?? 0; | 51 | $inquiryNumber = $countInfo->inquiry_num ?? 0; |
| 51 | } | 52 | } |
| 52 | - $data = ['product'=>$productNumber,'blog'=>$blogNumber,'news'=>$newsNumber,'key'=>$keyNumber,'inquiry'=>$inquiryNumber]; | 53 | + $data = ['product'=>$productNumber,'blog'=>($blogNumber + $aiBlogNumber),'news'=>$newsNumber,'key'=>$keyNumber,'inquiry'=>$inquiryNumber]; |
| 53 | Cache::add('product_blog_news_'.$project_id,$data,30 * 60); | 54 | Cache::add('product_blog_news_'.$project_id,$data,30 * 60); |
| 54 | } | 55 | } |
| 55 | }catch (\Exception $e){ | 56 | }catch (\Exception $e){ |
| @@ -24,7 +24,7 @@ class CosService | @@ -24,7 +24,7 @@ class CosService | ||
| 24 | * @method :post | 24 | * @method :post |
| 25 | * @time :2023/7/19 15:28 | 25 | * @time :2023/7/19 15:28 |
| 26 | */ | 26 | */ |
| 27 | - public function uploadFile(&$files,$path,$filename, $binary = false,$watermarkOptions = '') | 27 | + public function uploadFile(&$files, $path, $filename, $binary = false, $watermarkOptions = '') |
| 28 | { | 28 | { |
| 29 | $cos = config('filesystems.disks.cos'); | 29 | $cos = config('filesystems.disks.cos'); |
| 30 | $cosClient = new Client([ | 30 | $cosClient = new Client([ |
| @@ -34,7 +34,9 @@ class CosService | @@ -34,7 +34,9 @@ class CosService | ||
| 34 | 'secretKey' => $cos['credentials']['secretKey'], | 34 | 'secretKey' => $cos['credentials']['secretKey'], |
| 35 | ], | 35 | ], |
| 36 | ]); | 36 | ]); |
| 37 | - $key = $path.'/'.$filename; | 37 | + |
| 38 | + $key = $path . '/' . $filename; | ||
| 39 | + | ||
| 38 | // 判断是否为 Base64 编码的图片流文件 | 40 | // 判断是否为 Base64 编码的图片流文件 |
| 39 | if (Str::startsWith($files, 'data:image')) { | 41 | if (Str::startsWith($files, 'data:image')) { |
| 40 | // 分离 Base64 头部和数据部分 | 42 | // 分离 Base64 头部和数据部分 |
| @@ -42,18 +44,30 @@ class CosService | @@ -42,18 +44,30 @@ class CosService | ||
| 42 | // 解码 Base64 数据 | 44 | // 解码 Base64 数据 |
| 43 | $Body = base64_decode($base64Data); | 45 | $Body = base64_decode($base64Data); |
| 44 | if ($Body === false) { | 46 | if ($Body === false) { |
| 45 | - throw new \Exception("Base64 数据解码失败"); | 47 | + outMessage('upload_images',"解码失败"); |
| 48 | + return false; | ||
| 46 | } | 49 | } |
| 47 | } else { | 50 | } else { |
| 48 | // 如果不是 Base64 流文件,处理为普通文件上传 | 51 | // 如果不是 Base64 流文件,处理为普通文件上传 |
| 52 | + try { | ||
| 49 | $Body = $binary ? $files : fopen($files->getRealPath(), 'r'); | 53 | $Body = $binary ? $files : fopen($files->getRealPath(), 'r'); |
| 54 | + // 检查文件是否有效 | ||
| 55 | + if (!$Body) { | ||
| 56 | + outMessage('upload_images',"文件打开失败"); | ||
| 57 | + return false; | ||
| 58 | + } | ||
| 59 | + } catch (\Exception $e) { | ||
| 60 | + outMessage('upload_images',"文件处理失败: " . $e->getMessage()); | ||
| 61 | + return false; | ||
| 62 | + } | ||
| 50 | } | 63 | } |
| 64 | + try { | ||
| 51 | $options = [ | 65 | $options = [ |
| 52 | 'Bucket' => $cos['bucket'], | 66 | 'Bucket' => $cos['bucket'], |
| 53 | 'Key' => $key, | 67 | 'Key' => $key, |
| 54 | 'Body' => $Body, | 68 | 'Body' => $Body, |
| 55 | ]; | 69 | ]; |
| 56 | - //水印 | 70 | + // 水印处理 |
| 57 | if ($watermarkOptions) { | 71 | if ($watermarkOptions) { |
| 58 | $options['PicOperations'] = json_encode([ | 72 | $options['PicOperations'] = json_encode([ |
| 59 | 'is_pic_info' => 1, | 73 | 'is_pic_info' => 1, |
| @@ -65,10 +79,21 @@ class CosService | @@ -65,10 +79,21 @@ class CosService | ||
| 65 | ] | 79 | ] |
| 66 | ], true); | 80 | ], true); |
| 67 | } | 81 | } |
| 68 | - $res = $cosClient->putObject($options); | 82 | + $cosClient->putObject($options); |
| 83 | + } catch (\Exception $e) { | ||
| 84 | + // 记录上传失败日志 | ||
| 85 | + outMessage('upload_images',$e->getMessage()); | ||
| 86 | + return false; | ||
| 87 | + } finally { | ||
| 88 | + // 确保非二进制模式下关闭文件资源 | ||
| 89 | + if (!$binary && is_resource($Body)) { | ||
| 90 | + fclose($Body); | ||
| 91 | + } | ||
| 92 | + } | ||
| 69 | return $key; | 93 | return $key; |
| 70 | } | 94 | } |
| 71 | 95 | ||
| 96 | + | ||
| 72 | /** | 97 | /** |
| 73 | * @param $image_name | 98 | * @param $image_name |
| 74 | * @remark :获取图片访问链接 | 99 | * @remark :获取图片访问链接 |
-
请 注册 或 登录 后发表评论