正在显示
5 个修改的文件
包含
52 行增加
和
4 行删除
| @@ -18,6 +18,7 @@ yarn-error.log | @@ -18,6 +18,7 @@ yarn-error.log | ||
| 18 | /.vscode | 18 | /.vscode |
| 19 | composer.lock | 19 | composer.lock |
| 20 | app/Console/Commands/Test/Demo.php | 20 | app/Console/Commands/Test/Demo.php |
| 21 | +app/Console/Commands/Test/DataRecovery.php | ||
| 21 | /public/upload | 22 | /public/upload |
| 22 | /public/runtime | 23 | /public/runtime |
| 23 | public/nginx.htaccess | 24 | public/nginx.htaccess |
| @@ -119,7 +119,7 @@ class VideoTask extends Command | @@ -119,7 +119,7 @@ class VideoTask extends Command | ||
| 119 | */ | 119 | */ |
| 120 | public function sendSubTask() | 120 | public function sendSubTask() |
| 121 | { | 121 | { |
| 122 | - $subTask = KeywordVideoTaskLog::where(['status' => TaskSub::STATUS_INIT])->orderBy('id', 'asc')->limit($this->max_sub_task)->get(); | 122 | + $subTask = KeywordVideoTaskLog::where(['status' => KeywordVideoTaskLog::STATUS_INIT])->orderBy('id', 'asc')->limit($this->max_sub_task)->get(); |
| 123 | if ($subTask->isEmpty()) | 123 | if ($subTask->isEmpty()) |
| 124 | return true; | 124 | return true; |
| 125 | foreach ($subTask as $val) { | 125 | foreach ($subTask as $val) { |
| @@ -134,11 +134,12 @@ class VideoTask extends Command | @@ -134,11 +134,12 @@ class VideoTask extends Command | ||
| 134 | 'images' => $valData['images'] | 134 | 'images' => $valData['images'] |
| 135 | ], | 135 | ], |
| 136 | 'task_id' => $task_id, | 136 | 'task_id' => $task_id, |
| 137 | - 'callback_url' => url('a/getKeywordVideo?project_id='.$val->project_id.'&keyword_id='.$val->keyword_id.'&video='), | 137 | + 'callback_url' => env('APP_URL') . '/api/video_task_callback', |
| 138 | +// 'callback_url' => url('a/getKeywordVideo?project_id='.$val->project_id.'&keyword_id='.$val->keyword_id.'&video='), | ||
| 138 | ]; | 139 | ]; |
| 139 | $result = Http::post('http://216.250.255.116:7866/create_task', $data); | 140 | $result = Http::post('http://216.250.255.116:7866/create_task', $data); |
| 140 | $val->task_id = $task_id; | 141 | $val->task_id = $task_id; |
| 141 | - $val->status = KeywordVideoTaskLog::STATUS_RUNING; | 142 | + $val->status = KeywordVideoTaskLog::STATUS_RUNNING; |
| 142 | $val->request_result = $result; | 143 | $val->request_result = $result; |
| 143 | $val->save(); | 144 | $val->save(); |
| 144 | } | 145 | } |
| @@ -7,9 +7,13 @@ | @@ -7,9 +7,13 @@ | ||
| 7 | */ | 7 | */ |
| 8 | namespace App\Http\Controllers\Api; | 8 | namespace App\Http\Controllers\Api; |
| 9 | 9 | ||
| 10 | +use App\Models\Com\KeywordVideoTaskLog; | ||
| 11 | +use App\Models\Product\Keyword; | ||
| 10 | use App\Models\Visit\SyncSubmitTask; | 12 | use App\Models\Visit\SyncSubmitTask; |
| 11 | use App\Models\Visit\Visit; | 13 | use App\Models\Visit\Visit; |
| 14 | +use App\Services\ProjectServer; | ||
| 12 | use Illuminate\Http\Request; | 15 | use Illuminate\Http\Request; |
| 16 | +use Illuminate\Support\Facades\DB; | ||
| 13 | 17 | ||
| 14 | /** | 18 | /** |
| 15 | * Class NoticeController | 19 | * Class NoticeController |
| @@ -58,4 +62,44 @@ class NoticeController extends BaseController | @@ -58,4 +62,44 @@ class NoticeController extends BaseController | ||
| 58 | SyncSubmitTask::createTask($array, SyncSubmitTask::TYPE_VISIT); | 62 | SyncSubmitTask::createTask($array, SyncSubmitTask::TYPE_VISIT); |
| 59 | return $this->success([]); | 63 | return $this->success([]); |
| 60 | } | 64 | } |
| 65 | + | ||
| 66 | + /** | ||
| 67 | + * 生成视频任务回调 | ||
| 68 | + * @param Request $request | ||
| 69 | + * @return int | ||
| 70 | + */ | ||
| 71 | + public function videoTaskCallback(Request $request) | ||
| 72 | + { | ||
| 73 | + // 获取参数 | ||
| 74 | + $task_id = $request->input('task_id'); | ||
| 75 | + $status = intval($request->input('status', 0)); | ||
| 76 | + $thumb = $request->input('video_thumb'); | ||
| 77 | + $video = $request->input('embed_code'); | ||
| 78 | + $all = $request->all(); | ||
| 79 | + // 获取子任务 | ||
| 80 | + $log = KeywordVideoTaskLog::where(['task_id' => $task_id])->first(); | ||
| 81 | + if (empty($log)) | ||
| 82 | + return 200; | ||
| 83 | + // 更新子任务状态 更新任务信息 | ||
| 84 | + $log->status = KeywordVideoTaskLog::STATUS_FINISH; | ||
| 85 | + $log->result_status = $status; | ||
| 86 | + $log->result_info = json_encode($all); | ||
| 87 | + $log->save(); | ||
| 88 | + | ||
| 89 | + if ($status != 200) { | ||
| 90 | + return 200; | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + // 更新关键词信息 | ||
| 94 | + ProjectServer::useProject($log->project_id); | ||
| 95 | + $keyword = Keyword::where(['id' => $log->keyword_id])->first(); | ||
| 96 | + // 关键词可能已被删除 | ||
| 97 | + if (empty($keyword)) | ||
| 98 | + return 200; | ||
| 99 | + $keyword->video = $video; | ||
| 100 | + $keyword->video_thumb = $thumb; | ||
| 101 | + $keyword->save(); | ||
| 102 | + DB::disconnect('custom_mysql'); | ||
| 103 | + return 200; | ||
| 104 | + } | ||
| 61 | } | 105 | } |
| @@ -14,7 +14,8 @@ use App\Models\Base; | @@ -14,7 +14,8 @@ use App\Models\Base; | ||
| 14 | class KeywordVideoTaskLog extends Base | 14 | class KeywordVideoTaskLog extends Base |
| 15 | { | 15 | { |
| 16 | const STATUS_INIT = 0; | 16 | const STATUS_INIT = 0; |
| 17 | - const STATUS_RUNING = 1; | 17 | + const STATUS_RUNNING = 1; |
| 18 | + const STATUS_FINISH = 2; | ||
| 18 | 19 | ||
| 19 | protected $table = 'gl_keyword_video_task_log'; | 20 | protected $table = 'gl_keyword_video_task_log'; |
| 20 | } | 21 | } |
| @@ -24,3 +24,4 @@ Route::get('get_project_route', [\App\Http\Controllers\Api\PrivateController::cl | @@ -24,3 +24,4 @@ Route::get('get_project_route', [\App\Http\Controllers\Api\PrivateController::cl | ||
| 24 | Route::any('get_product_images', [\App\Http\Controllers\Api\ProductController::class, 'getImages'])->name('api.get_product_images'); | 24 | Route::any('get_product_images', [\App\Http\Controllers\Api\ProductController::class, 'getImages'])->name('api.get_product_images'); |
| 25 | Route::post('inquiry_submit', [\App\Http\Controllers\Api\InquiryController::class, 'submit'])->name('api.inquiry_submit'); | 25 | Route::post('inquiry_submit', [\App\Http\Controllers\Api\InquiryController::class, 'submit'])->name('api.inquiry_submit'); |
| 26 | 26 | ||
| 27 | +Route::post('video_task_callback', [\App\Http\Controllers\Api\NoticeController::class, 'videoTaskCallback'])->name('api.video_task_callback'); |
-
请 注册 或 登录 后发表评论