合并分支 'lyh-server' 到 'master'
Lyh server 查看合并请求 !2484
正在显示
6 个修改的文件
包含
180 行增加
和
25 行删除
| @@ -11,8 +11,10 @@ namespace App\Console\Commands\Ai; | @@ -11,8 +11,10 @@ namespace App\Console\Commands\Ai; | ||
| 11 | 11 | ||
| 12 | use App\Models\Product\Keyword; | 12 | use App\Models\Product\Keyword; |
| 13 | use App\Models\Product\Product; | 13 | use App\Models\Product\Product; |
| 14 | +use App\Models\Project\AiVideoAutoLog; | ||
| 14 | use App\Models\Project\DeployOptimize; | 15 | use App\Models\Project\DeployOptimize; |
| 15 | use App\Models\Project\Project; | 16 | use App\Models\Project\Project; |
| 17 | +use App\Services\MidJourneyService; | ||
| 16 | use App\Services\ProjectServer; | 18 | use App\Services\ProjectServer; |
| 17 | use Illuminate\Console\Command; | 19 | use Illuminate\Console\Command; |
| 18 | use Illuminate\Support\Facades\DB; | 20 | use Illuminate\Support\Facades\DB; |
| @@ -33,7 +35,7 @@ class AiVideoAutoPublish extends Command | @@ -33,7 +35,7 @@ class AiVideoAutoPublish extends Command | ||
| 33 | * | 35 | * |
| 34 | * @var string | 36 | * @var string |
| 35 | */ | 37 | */ |
| 36 | - protected $signature = 'ai_video_auto_publish'; | 38 | + protected $signature = 'ai_video_auto_publish {action}'; |
| 37 | 39 | ||
| 38 | /** | 40 | /** |
| 39 | * The console command description. | 41 | * The console command description. |
| @@ -48,12 +50,12 @@ class AiVideoAutoPublish extends Command | @@ -48,12 +50,12 @@ class AiVideoAutoPublish extends Command | ||
| 48 | 50 | ||
| 49 | /** | 51 | /** |
| 50 | * @remark :普通项目--自动发布 | 52 | * @remark :普通项目--自动发布 |
| 51 | - * @name :auto_publish | 53 | + * @name :auto_six_publish |
| 52 | * @author :lyh | 54 | * @author :lyh |
| 53 | * @method :post | 55 | * @method :post |
| 54 | * @time :2025/8/1 15:22 | 56 | * @time :2025/8/1 15:22 |
| 55 | */ | 57 | */ |
| 56 | - public function auto_six_publish(){ | 58 | + public function auto_publish(){ |
| 57 | $this->output('开始自动发布Video文章'); | 59 | $this->output('开始自动发布Video文章'); |
| 58 | $projectModel = new Project(); | 60 | $projectModel = new Project(); |
| 59 | $optimizeModel = new DeployOptimize(); | 61 | $optimizeModel = new DeployOptimize(); |
| @@ -81,7 +83,10 @@ class AiVideoAutoPublish extends Command | @@ -81,7 +83,10 @@ class AiVideoAutoPublish extends Command | ||
| 81 | $data = $this->getVideoInfo(); | 83 | $data = $this->getVideoInfo(); |
| 82 | if(!empty($data)){ | 84 | if(!empty($data)){ |
| 83 | //写入一条零时生成视频记录 | 85 | //写入一条零时生成视频记录 |
| 84 | - | 86 | + $aiVideoAutoLogModel = new AiVideoAutoLog(); |
| 87 | + $aiVideoAutoLogModel->addReturnId( | ||
| 88 | + ['project_id'=>$item['id'],'title'=>$data['title'],'remark'=>$data['remark'],'images'=>json_encode($data['images'],true),'date'=>date('Y-m-d')] | ||
| 89 | + ); | ||
| 85 | } | 90 | } |
| 86 | DB::disconnect('custom_mysql'); | 91 | DB::disconnect('custom_mysql'); |
| 87 | } | 92 | } |
| @@ -127,6 +132,35 @@ class AiVideoAutoPublish extends Command | @@ -127,6 +132,35 @@ class AiVideoAutoPublish extends Command | ||
| 127 | } | 132 | } |
| 128 | 133 | ||
| 129 | /** | 134 | /** |
| 135 | + * @remark :组装缺少图片数据-推送至发送平台 | ||
| 136 | + * @name :send_video | ||
| 137 | + * @author :lyh | ||
| 138 | + * @method :post | ||
| 139 | + * @time :2025/8/2 10:37 | ||
| 140 | + */ | ||
| 141 | + public function auto_send_video(){ | ||
| 142 | + while (true){ | ||
| 143 | + $aiVideoAutoLogModel = new AiVideoAutoLog(); | ||
| 144 | + $lists = $aiVideoAutoLogModel->list(['status'=>0]); | ||
| 145 | + if(empty($lists)){ | ||
| 146 | + sleep(60); | ||
| 147 | + } | ||
| 148 | + foreach ($lists as $item){ | ||
| 149 | + if(count($item['images']) < 6){ | ||
| 150 | + //需要生成图片 | ||
| 151 | + $content = "{$item['remark']},{$item['title']},4K,高清 --no logo --ar 16:9"; | ||
| 152 | + $midJourneyService = new MidJourneyService(); | ||
| 153 | + $result = $midJourneyService->imagine($content); | ||
| 154 | + dd($result); | ||
| 155 | + }else{ | ||
| 156 | + //提交到待执行 | ||
| 157 | + $aiVideoAutoLogModel->edit(['status'=>1],['id'=>$item['id']]); | ||
| 158 | + } | ||
| 159 | + } | ||
| 160 | + } | ||
| 161 | + } | ||
| 162 | + | ||
| 163 | + /** | ||
| 130 | * @remark : | 164 | * @remark : |
| 131 | * @name :getAiVideoParam | 165 | * @name :getAiVideoParam |
| 132 | * @author :lyh | 166 | * @author :lyh |
| @@ -25,6 +25,7 @@ use App\Models\Template\TemplateTypeMain; | @@ -25,6 +25,7 @@ use App\Models\Template\TemplateTypeMain; | ||
| 25 | use App\Models\WebSetting\WebSetting; | 25 | use App\Models\WebSetting\WebSetting; |
| 26 | use App\Services\AiBlogService; | 26 | use App\Services\AiBlogService; |
| 27 | use App\Services\Geo\GeoService; | 27 | use App\Services\Geo\GeoService; |
| 28 | +use App\Services\MidJourneyService; | ||
| 28 | use App\Services\ProjectServer; | 29 | use App\Services\ProjectServer; |
| 29 | use Illuminate\Console\Command; | 30 | use Illuminate\Console\Command; |
| 30 | use Illuminate\Support\Facades\DB; | 31 | use Illuminate\Support\Facades\DB; |
| @@ -46,27 +47,10 @@ class lyhDemo extends Command | @@ -46,27 +47,10 @@ class lyhDemo extends Command | ||
| 46 | protected $description = '更新路由'; | 47 | protected $description = '更新路由'; |
| 47 | 48 | ||
| 48 | public function handle(){ | 49 | public function handle(){ |
| 49 | - $projectModel = new Project(); | ||
| 50 | - $lists = $projectModel->list(['delete_status' => 0,'project_type'=>0,'extend_type'=>0,'type'=>['in',[1,2,3,4,6]]], 'id', ['id','created_at']); | ||
| 51 | - $buildModel = new DeployBuild(); | ||
| 52 | - foreach ($lists as $item){ | ||
| 53 | - echo date('Y-m-d H:i:s') . '开始--项目的id:'. $item['id'] . PHP_EOL; | ||
| 54 | - $buildInfo = $buildModel->read(['project_id'=>$item['id']],['plan','seo_plan']); | ||
| 55 | - if($buildInfo['seo_plan'] != 0){ | ||
| 56 | - $projectModel->edit(['version'=>7],['id'=>$item['id']]); | ||
| 57 | - continue; | ||
| 58 | - } | ||
| 59 | - if(in_array($buildInfo['plan'],[4,5,15,16,17])){ | ||
| 60 | - $projectModel->edit(['version'=>0],['id'=>$item['id']]); | ||
| 61 | - }else{ | ||
| 62 | - if($item['created_at'] > '2025-04-12 00:00:00'){ | ||
| 63 | - $projectModel->edit(['version'=>7],['id'=>$item['id']]); | ||
| 64 | - }else{ | ||
| 65 | - $projectModel->edit(['version'=>6],['id'=>$item['id']]); | ||
| 66 | - } | ||
| 67 | - } | ||
| 68 | - } | ||
| 69 | - return true; | 50 | + $content = "{Introducing the cutting-edge product from Zhejiang Yuexiang Gas Technology Co., Ltd., the Bracket Gas Flowmeter. This innovative gas flowmeter is designed to provide accurate and reliable measurements for a wide range of industrial applications,Equipped with advanced technology and precision components, the Bracket Gas Flowmeter ensures exceptional performance and durability. It offers highly accurate gas flow readings, allowing users to closely monitor and control gas consumption in various processes. The meter's user-friendly interface displays real-time flow rates and totalized flow data, facilitating efficient and convenient data management,With its robust construction and corrosion-resistant materials, the Bracket Gas Flowmeter guarantees long-term reliability, even in harsh operating conditions. It is compatible with various gases such as natural gas, propane, and hydrogen, making it a versatile choice for multiple industries including oil and gas, chemical, and manufacturing,Furthermore, the Bracket Gas Flowmeter is engineered with ease of installation and maintenance in mind. Its compact and space-saving design allows for flexible mounting options, while its modular construction enables quick and hassle-free maintenance. Additionally, it meets international standards for accuracy and safety, ensuring compliance with industry regulations,Choose the Bracket Gas Flowmeter for precise and efficient gas flow measurement, backed by the expertise and commitment of Zhejiang Yuexiang Gas Technology Co., Ltd},{Shop Quality Brackets: Top China Products & Services for Your Needs},4K,高清 --no logo --ar 16:9"; |
| 51 | + $midJourneyService = new MidJourneyService(); | ||
| 52 | + $result = $midJourneyService->imagine($content); | ||
| 53 | + dd($result); | ||
| 70 | } | 54 | } |
| 71 | 55 | ||
| 72 | /** | 56 | /** |
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :AiVideoController.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2025/8/2 11:18 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Http\Controllers\Api; | ||
| 11 | + | ||
| 12 | +use App\Enums\Common\Code; | ||
| 13 | + | ||
| 14 | +class AiVideoController extends BaseController | ||
| 15 | +{ | ||
| 16 | + /** | ||
| 17 | + * @remark :回调方法 | ||
| 18 | + * @name :ImageCallBack | ||
| 19 | + * @author :lyh | ||
| 20 | + * @method :post | ||
| 21 | + * @time :2025/8/2 11:19 | ||
| 22 | + */ | ||
| 23 | + public function ImageCallBack(){ | ||
| 24 | + $data = $this->param; | ||
| 25 | + @file_put_contents(storage_path('logs/lyh_error.log'), var_export($data, true) . PHP_EOL, FILE_APPEND); | ||
| 26 | + $this->response('success'); | ||
| 27 | + } | ||
| 28 | +} |
| @@ -9,9 +9,24 @@ | @@ -9,9 +9,24 @@ | ||
| 9 | 9 | ||
| 10 | namespace App\Models\Project; | 10 | namespace App\Models\Project; |
| 11 | 11 | ||
| 12 | +use App\Helper\Arr; | ||
| 12 | use App\Models\Base; | 13 | use App\Models\Base; |
| 13 | 14 | ||
| 14 | class AiVideoAutoLog extends Base | 15 | class AiVideoAutoLog extends Base |
| 15 | { | 16 | { |
| 16 | protected $table = 'gl_ai_video_auto_log'; | 17 | protected $table = 'gl_ai_video_auto_log'; |
| 18 | + | ||
| 19 | + /** | ||
| 20 | + * @remark :获取器图片集合 | ||
| 21 | + * @name :getImagesAttribute | ||
| 22 | + * @author :lyh | ||
| 23 | + * @method :post | ||
| 24 | + * @time :2025/8/2 10:45 | ||
| 25 | + */ | ||
| 26 | + public function getImagesAttribute($value){ | ||
| 27 | + if(!empty($value)){ | ||
| 28 | + $value = Arr::s2a($value); | ||
| 29 | + } | ||
| 30 | + return $value; | ||
| 31 | + } | ||
| 17 | } | 32 | } |
app/Services/MidJourneyService.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :MidJourneyService.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2025/8/2 10:48 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Services; | ||
| 11 | + | ||
| 12 | +use Illuminate\Support\Facades\Http; | ||
| 13 | + | ||
| 14 | +class MidJourneyService | ||
| 15 | +{ | ||
| 16 | + /** | ||
| 17 | + * 请求域名 | ||
| 18 | + * @var string | ||
| 19 | + */ | ||
| 20 | + public $url = 'https://api.cmer.com'; | ||
| 21 | + | ||
| 22 | + public $header = [ | ||
| 23 | + 'apikey' => 'UkzZljFv83Z2qBi5YR1o3f2otAVWtug6', | ||
| 24 | + 'X-CmerApi-Host' => 'aiccmj.p.cmer.com', | ||
| 25 | + ]; | ||
| 26 | + | ||
| 27 | + /** | ||
| 28 | + * @remark :提交生成图片 | ||
| 29 | + * @name :imagine | ||
| 30 | + * @author :lyh | ||
| 31 | + * @method :post | ||
| 32 | + * @time :2025/8/2 10:50 | ||
| 33 | + */ | ||
| 34 | + public function imagine($content, string $refer_img = ''){ | ||
| 35 | + try { | ||
| 36 | + $data = ['prompt' => $content]; | ||
| 37 | + //回调地址 | ||
| 38 | + $data['callback_url'] = route('api.ImageCallBack'); | ||
| 39 | + $result = Http::withHeaders($this->header)->withoutVerifying()->post($this->url.'/v1/api/trigger/imagine', $data); | ||
| 40 | + $json = $result->json(); | ||
| 41 | + }catch (\Throwable $e){ | ||
| 42 | + dump($e->getMessage()); | ||
| 43 | + $json = []; | ||
| 44 | + } | ||
| 45 | + return $json ?: []; | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + /** | ||
| 49 | + * 扩展图片 | ||
| 50 | + * @param $index | ||
| 51 | + * @param $msg_id | ||
| 52 | + * @param $msg_hash | ||
| 53 | + * @param $trigger_id | ||
| 54 | + * @return array|mixed | ||
| 55 | + */ | ||
| 56 | + public function upscale($index, $msg_id, $msg_hash, $trigger_id){ | ||
| 57 | + try { | ||
| 58 | + $result = Http::withHeaders($this->header)->withoutVerifying()->post($this->url.'/v1/api/trigger/upscale', [ | ||
| 59 | + "index" => $index, | ||
| 60 | + "msg_id" => $msg_id, | ||
| 61 | + "msg_hash" => $msg_hash, | ||
| 62 | + "trigger_id" => $trigger_id | ||
| 63 | + ]); | ||
| 64 | + $json = $result->json(); | ||
| 65 | + }catch (\Throwable $e){ | ||
| 66 | + $json = []; | ||
| 67 | + } | ||
| 68 | + return $json; | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + /** | ||
| 72 | + * 优化图片 | ||
| 73 | + * @param $index | ||
| 74 | + * @param $msg_id | ||
| 75 | + * @param $msg_hash | ||
| 76 | + * @param $trigger_id | ||
| 77 | + * @return array|mixed | ||
| 78 | + */ | ||
| 79 | + public function variation($index, $msg_id, $msg_hash, $trigger_id){ | ||
| 80 | + try { | ||
| 81 | + $result = Http::withHeaders($this->header)->withoutVerifying()->post($this->url.'/v1/api/trigger/variation', [ | ||
| 82 | + "index" => $index, | ||
| 83 | + "msg_id" => $msg_id, | ||
| 84 | + "msg_hash" => $msg_hash, | ||
| 85 | + "trigger_id" => $trigger_id | ||
| 86 | + ]); | ||
| 87 | + $json = $result->json(); | ||
| 88 | + }catch (\Throwable $e){ | ||
| 89 | + $json = []; | ||
| 90 | + } | ||
| 91 | + return $json; | ||
| 92 | + } | ||
| 93 | +} |
| @@ -17,6 +17,7 @@ use Illuminate\Support\Facades\Route; | @@ -17,6 +17,7 @@ use Illuminate\Support\Facades\Route; | ||
| 17 | Route::middleware('auth:sanctum')->get('/user', function (Request $request) { | 17 | Route::middleware('auth:sanctum')->get('/user', function (Request $request) { |
| 18 | return $request->user(); | 18 | return $request->user(); |
| 19 | }); | 19 | }); |
| 20 | +Route::any('ImageCallBack', [\App\Http\Controllers\Api\AiVideoController::class, 'ImageCallBack'])->name('api.ImageCallBack'); | ||
| 20 | Route::any('stripeWebhook', [\App\Http\Controllers\Api\PayStripeController::class, 'handleWebhook'])->name('api.handleWebhook'); | 21 | Route::any('stripeWebhook', [\App\Http\Controllers\Api\PayStripeController::class, 'handleWebhook'])->name('api.handleWebhook'); |
| 21 | Route::any('traffic_visit', [\App\Http\Controllers\Api\NoticeController::class, 'trafficVisit'])->name('api.traffic_visit'); | 22 | Route::any('traffic_visit', [\App\Http\Controllers\Api\NoticeController::class, 'trafficVisit'])->name('api.traffic_visit'); |
| 22 | Route::get('optimize_project_list', [\App\Http\Controllers\Api\PrivateController::class, 'optimizeProjectList'])->name('api.optimize_project_list'); | 23 | Route::get('optimize_project_list', [\App\Http\Controllers\Api\PrivateController::class, 'optimizeProjectList'])->name('api.optimize_project_list'); |
-
请 注册 或 登录 后发表评论