Merge remote-tracking branch 'origin/master' into akun
正在显示
10 个修改的文件
包含
212 行增加
和
64 行删除
| 1 | -<?php | ||
| 2 | -/** | ||
| 3 | - * @remark : | ||
| 4 | - * @name :GenerateVideo.php | ||
| 5 | - * @author :lyh | ||
| 6 | - * @method :post | ||
| 7 | - * @time :2024/2/26 11:47 | ||
| 8 | - */ | ||
| 9 | - | ||
| 10 | -namespace App\Console\Commands\KeywordInVideo; | ||
| 11 | - | ||
| 12 | -use Illuminate\Console\Command; | ||
| 13 | - | ||
| 14 | -class GenerateVideo extends Command | ||
| 15 | -{ | ||
| 16 | - /** | ||
| 17 | - * The name and signature of the console command. | ||
| 18 | - * | ||
| 19 | - * @var string | ||
| 20 | - */ | ||
| 21 | - protected $signature = 'generate_video'; | ||
| 22 | - | ||
| 23 | - /** | ||
| 24 | - * The console command description. | ||
| 25 | - * | ||
| 26 | - * @var string | ||
| 27 | - */ | ||
| 28 | - protected $description = '根据关键词生成视频'; | ||
| 29 | - | ||
| 30 | - /** | ||
| 31 | - * Create a new command instance. | ||
| 32 | - * | ||
| 33 | - * @return void | ||
| 34 | - */ | ||
| 35 | - public function __construct() | ||
| 36 | - { | ||
| 37 | - parent::__construct(); | ||
| 38 | - } | ||
| 39 | - | ||
| 40 | - public function handle() | ||
| 41 | - { | ||
| 42 | - | ||
| 43 | - } | ||
| 44 | -} |
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * Created by PhpStorm. | ||
| 4 | + * User: zhl | ||
| 5 | + * Date: 2024/02/26 | ||
| 6 | + * Time: 10:13 | ||
| 7 | + */ | ||
| 8 | +namespace App\Console\Commands\KeywordInVideo; | ||
| 9 | + | ||
| 10 | +use App\Console\Commands\Model; | ||
| 11 | +use App\Console\Commands\TaskSub; | ||
| 12 | +use App\Models\Com\KeywordVideoTask; | ||
| 13 | +use App\Models\Com\KeywordVideoTaskLog; | ||
| 14 | +use App\Models\Product\Keyword; | ||
| 15 | +use App\Services\ProjectServer; | ||
| 16 | +use Illuminate\Console\Command; | ||
| 17 | +use Illuminate\Support\Facades\Http; | ||
| 18 | +use Illuminate\Support\Facades\Log; | ||
| 19 | + | ||
| 20 | +class VideoTask extends Command | ||
| 21 | +{ | ||
| 22 | + /** | ||
| 23 | + * The name and signature of the console command. | ||
| 24 | + * | ||
| 25 | + * @var string | ||
| 26 | + */ | ||
| 27 | + protected $signature = 'video_task'; | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * The console command description. | ||
| 31 | + * | ||
| 32 | + * @var string | ||
| 33 | + */ | ||
| 34 | + protected $description = '视频推广任务'; | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * Create a new command instance. | ||
| 38 | + * | ||
| 39 | + * @return void | ||
| 40 | + */ | ||
| 41 | + public function __construct() | ||
| 42 | + { | ||
| 43 | + parent::__construct(); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * @var int 最大子任务 | ||
| 48 | + */ | ||
| 49 | + public $max_sub_task = 800; | ||
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * @return bool | ||
| 53 | + */ | ||
| 54 | + public function handle() | ||
| 55 | + { | ||
| 56 | + Log::info('开始视频推广任务'); | ||
| 57 | + $this->createSubTask(); | ||
| 58 | + $this->sendSubTask(); | ||
| 59 | + Log::info('结束视频推广任务'); | ||
| 60 | + return true; | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + /** | ||
| 64 | + * 创建子任务 | ||
| 65 | + * TODO 获取需要生成子任务的项目,获取项目中未生成视频的关键词,通过关键词生成初始化子任务 | ||
| 66 | + * @return bool | ||
| 67 | + */ | ||
| 68 | + public function createSubTask() | ||
| 69 | + { | ||
| 70 | + $sub_task_num = $this->max_sub_task; | ||
| 71 | + while (true) { | ||
| 72 | + if ($sub_task_num <= 0){ | ||
| 73 | + break; | ||
| 74 | + } | ||
| 75 | + $task_project = KeywordVideoTask::where(['status' => KeywordVideoTask::STATUS_OPEN])->orderBy('sort', 'desc')->first(); | ||
| 76 | + if (empty($task_project)){ | ||
| 77 | + break; | ||
| 78 | + } | ||
| 79 | + ProjectServer::useProject($task_project->project_id); | ||
| 80 | + $keyword = $this->getProjectKeyword(); | ||
| 81 | + // 已经没有需要生成视频的关键词 | ||
| 82 | + if (FALSE == $keyword->isEmpty()) { | ||
| 83 | + $task_project->status = KeywordVideoTask::STATUS_CLOSE; | ||
| 84 | + $task_project->save(); | ||
| 85 | + continue; | ||
| 86 | + } | ||
| 87 | + foreach ($keyword as $val) { | ||
| 88 | + $log = KeywordVideoTaskLog::where(['project_id' => $task_project->project_id, 'keyword_id' => $val->id])->first(); | ||
| 89 | + if ($log){ | ||
| 90 | + continue; | ||
| 91 | + } | ||
| 92 | + $array = [ | ||
| 93 | + 'project_id' => $task_project->project_id, | ||
| 94 | + 'keyword_id' => $val->id, | ||
| 95 | + 'keyword' => $val->title, | ||
| 96 | + 'data' => json_encode(['url' => '', 'description' => '', 'images' => [], 'keywords' => []]), | ||
| 97 | + 'status' => KeywordVideoTaskLog::STATUS_INIT, | ||
| 98 | + 'updated_at' => date('Y-m-d H:i:s'), | ||
| 99 | + 'created_at' => date('Y-m-d H:i:s'), | ||
| 100 | + ]; | ||
| 101 | + KeywordVideoTaskLog::insert($array); | ||
| 102 | + $sub_task_num--; | ||
| 103 | + } | ||
| 104 | + $task_project->status = KeywordVideoTask::STATUS_CLOSE; | ||
| 105 | + $task_project->save(); | ||
| 106 | + } | ||
| 107 | + return true; | ||
| 108 | + } | ||
| 109 | + | ||
| 110 | + /** | ||
| 111 | + * 发送子任务 | ||
| 112 | + * @return bool | ||
| 113 | + */ | ||
| 114 | + public function sendSubTask() | ||
| 115 | + { | ||
| 116 | + $subTask = KeywordVideoTaskLog::where(['status' => TaskSub::STATUS_INIT])->orderBy('id', 'asc')->limit($this->max_sub_task)->get(); | ||
| 117 | + if ($subTask->isEmpty()) | ||
| 118 | + return true; | ||
| 119 | + foreach ($subTask as $val) { | ||
| 120 | + $task_id = 'v6-' . uniqid(); | ||
| 121 | + $data = [ | ||
| 122 | + 'project_data' => [ | ||
| 123 | + 'tag_url' => '', | ||
| 124 | + 'title' => '', | ||
| 125 | + 'keywords' => [], | ||
| 126 | + 'description' => '', | ||
| 127 | + 'images' => '' | ||
| 128 | + ], | ||
| 129 | + 'task_id' => $task_id, | ||
| 130 | + 'callback_url' => '', | ||
| 131 | + ]; | ||
| 132 | + $result = Http::post('http://216.250.255.116:7866/create_task', $data); | ||
| 133 | + | ||
| 134 | + $val->task_id = $task_id; | ||
| 135 | + $val->status = STATUS_RUNING::STATUS_RUNING; | ||
| 136 | + $val->request_result = $result; | ||
| 137 | + $val->save(); | ||
| 138 | + } | ||
| 139 | + return true; | ||
| 140 | + } | ||
| 141 | + | ||
| 142 | + /** | ||
| 143 | + * 获取未生成页面的关键词 | ||
| 144 | + * @return mixed | ||
| 145 | + */ | ||
| 146 | + public function getProjectKeyword() | ||
| 147 | + { | ||
| 148 | + $keyword = Keyword::where('video', null)->whereNotNull('keyword_content')->inRandomOrder()->take(100)->get(); | ||
| 149 | + return $keyword; | ||
| 150 | + } | ||
| 151 | + | ||
| 152 | + /** | ||
| 153 | + * 获取需要处理的任务 | ||
| 154 | + * @return int | ||
| 155 | + */ | ||
| 156 | + public function getTaskProject() | ||
| 157 | + { | ||
| 158 | +// $task_project = Model::where(['status' => Model::STATUS_OPEN])->orderBy('sort', 'desc')->first(); | ||
| 159 | + $project_id = 110; | ||
| 160 | + return $project_id; | ||
| 161 | + } | ||
| 162 | +} |
| 1 | <?php | 1 | <?php |
| 2 | /** | 2 | /** |
| 3 | * @remark : | 3 | * @remark : |
| 4 | - * @name :KeywordController.php | 4 | + * @name :KeywordVideoController.php |
| 5 | * @author :lyh | 5 | * @author :lyh |
| 6 | * @method :post | 6 | * @method :post |
| 7 | * @time :2024/2/26 9:23 | 7 | * @time :2024/2/26 9:23 |
| @@ -11,9 +11,9 @@ namespace App\Http\Controllers\Aside\Com; | @@ -11,9 +11,9 @@ namespace App\Http\Controllers\Aside\Com; | ||
| 11 | 11 | ||
| 12 | use App\Enums\Common\Code; | 12 | use App\Enums\Common\Code; |
| 13 | use App\Http\Controllers\Aside\BaseController; | 13 | use App\Http\Controllers\Aside\BaseController; |
| 14 | -use App\Models\Com\PromotionKeyword; | 14 | +use App\Models\Com\KeywordVideoTask; |
| 15 | 15 | ||
| 16 | -class KeywordController extends BaseController | 16 | +class KeywordVideoController extends BaseController |
| 17 | { | 17 | { |
| 18 | /** | 18 | /** |
| 19 | * @remark :任务列表 | 19 | * @remark :任务列表 |
| @@ -23,7 +23,7 @@ class KeywordController extends BaseController | @@ -23,7 +23,7 @@ class KeywordController extends BaseController | ||
| 23 | * @time :2024/2/26 11:36 | 23 | * @time :2024/2/26 11:36 |
| 24 | */ | 24 | */ |
| 25 | public function lists(){ | 25 | public function lists(){ |
| 26 | - $keywordModel = new PromotionKeyword(); | 26 | + $keywordModel = new KeywordVideoTask(); |
| 27 | $lists = $keywordModel->lists($this->map,$this->page,$this->row); | 27 | $lists = $keywordModel->lists($this->map,$this->page,$this->row); |
| 28 | $this->response('success',Code::SUCCESS,$lists); | 28 | $this->response('success',Code::SUCCESS,$lists); |
| 29 | } | 29 | } |
| @@ -43,7 +43,7 @@ class KeywordController extends BaseController | @@ -43,7 +43,7 @@ class KeywordController extends BaseController | ||
| 43 | 'project_id.required' => '项目唯一标识不为空', | 43 | 'project_id.required' => '项目唯一标识不为空', |
| 44 | 'number.required' => 'number不为空', | 44 | 'number.required' => 'number不为空', |
| 45 | ]); | 45 | ]); |
| 46 | - $keywordModel = new PromotionKeyword(); | 46 | + $keywordModel = new KeywordVideoTask(); |
| 47 | $rs = $keywordModel->add($this->param); | 47 | $rs = $keywordModel->add($this->param); |
| 48 | if($rs === false){ | 48 | if($rs === false){ |
| 49 | $this->response('添加失败',Code::SYSTEM_ERROR); | 49 | $this->response('添加失败',Code::SYSTEM_ERROR); |
| @@ -64,7 +64,7 @@ class KeywordController extends BaseController | @@ -64,7 +64,7 @@ class KeywordController extends BaseController | ||
| 64 | ], [ | 64 | ], [ |
| 65 | 'id.required' => '主键标识不为空', | 65 | 'id.required' => '主键标识不为空', |
| 66 | ]); | 66 | ]); |
| 67 | - $keywordModel = new PromotionKeyword(); | 67 | + $keywordModel = new KeywordVideoTask(); |
| 68 | $rs = $keywordModel->edit(['sort'=>$this->param['sort']],['id'=>$this->param['id']]); | 68 | $rs = $keywordModel->edit(['sort'=>$this->param['sort']],['id'=>$this->param['id']]); |
| 69 | if($rs === false){ | 69 | if($rs === false){ |
| 70 | $this->response('编辑失败',Code::SYSTEM_ERROR); | 70 | $this->response('编辑失败',Code::SYSTEM_ERROR); |
| @@ -15,7 +15,7 @@ use App\Rules\Ids; | @@ -15,7 +15,7 @@ use App\Rules\Ids; | ||
| 15 | use Illuminate\Http\Request; | 15 | use Illuminate\Http\Request; |
| 16 | 16 | ||
| 17 | /** | 17 | /** |
| 18 | - * Class KeywordController | 18 | + * Class KeywordVideoController |
| 19 | * @package App\Http\Controllers\Bside | 19 | * @package App\Http\Controllers\Bside |
| 20 | * @author zbj | 20 | * @author zbj |
| 21 | * @date 2023/4/15 | 21 | * @date 2023/4/15 |
| @@ -153,6 +153,7 @@ class MonthCountLogic extends BaseLogic | @@ -153,6 +153,7 @@ class MonthCountLogic extends BaseLogic | ||
| 153 | $source = DB::connection('custom_mysql')->table('gl_customer_visit') | 153 | $source = DB::connection('custom_mysql')->table('gl_customer_visit') |
| 154 | ->select('referrer_url', DB::raw('COUNT(*) as count')) | 154 | ->select('referrer_url', DB::raw('COUNT(*) as count')) |
| 155 | ->groupBy('referrer_url') | 155 | ->groupBy('referrer_url') |
| 156 | + ->where('referrer_url','!=','') | ||
| 156 | ->whereBetween('updated_date', [$startTime,$endTime]) | 157 | ->whereBetween('updated_date', [$startTime,$endTime]) |
| 157 | ->orderByDesc('count')->limit(10)->get()->toArray(); | 158 | ->orderByDesc('count')->limit(10)->get()->toArray(); |
| 158 | $arr['source'] = $source; | 159 | $arr['source'] = $source; |
| @@ -12,6 +12,7 @@ namespace App\Http\Logic\Bside\Scoring; | @@ -12,6 +12,7 @@ namespace App\Http\Logic\Bside\Scoring; | ||
| 12 | use App\Http\Logic\Bside\BaseLogic; | 12 | use App\Http\Logic\Bside\BaseLogic; |
| 13 | use App\Models\Scoring\RatingQuestion; | 13 | use App\Models\Scoring\RatingQuestion; |
| 14 | use App\Models\Scoring\ScoringSystem; | 14 | use App\Models\Scoring\ScoringSystem; |
| 15 | +use AWS\CRT\Log; | ||
| 15 | 16 | ||
| 16 | class RatingLogic extends BaseLogic | 17 | class RatingLogic extends BaseLogic |
| 17 | { | 18 | { |
| @@ -77,6 +78,9 @@ class RatingLogic extends BaseLogic | @@ -77,6 +78,9 @@ class RatingLogic extends BaseLogic | ||
| 77 | } | 78 | } |
| 78 | $str = trim($str,'&'); | 79 | $str = trim($str,'&'); |
| 79 | $url = "http://www.quanqiusou.cn/extend_api/api/service_score.php?postid=$postId&token=$token&ftype=$fType&$str"; | 80 | $url = "http://www.quanqiusou.cn/extend_api/api/service_score.php?postid=$postId&token=$token&ftype=$fType&$str"; |
| 80 | - return http_get($url,['charset=utf-8']); | 81 | + $rs = http_get($url,['charset=utf-8']); |
| 82 | + @file_put_contents(storage_path('logs/lyh_error.log'), var_export($url, true) . PHP_EOL, FILE_APPEND); | ||
| 83 | + @file_put_contents(storage_path('logs/lyh_error.log'), var_export($rs, true) . PHP_EOL, FILE_APPEND); | ||
| 84 | + return $rs; | ||
| 81 | } | 85 | } |
| 82 | } | 86 | } |
| @@ -228,11 +228,13 @@ class TranslateLogic extends BaseLogic | @@ -228,11 +228,13 @@ class TranslateLogic extends BaseLogic | ||
| 228 | */ | 228 | */ |
| 229 | public function translateSave(){ | 229 | public function translateSave(){ |
| 230 | $data = []; | 230 | $data = []; |
| 231 | - //处理传递的data | ||
| 232 | - foreach ($this->param['data'] as $k => $v){ | ||
| 233 | - if(!empty($v) && is_array($v)){ | ||
| 234 | - foreach ($v as $text => $translate){ | ||
| 235 | - $data[$text] = $translate; | 231 | + if(!empty($this->param['data'])){ |
| 232 | + //处理传递的data | ||
| 233 | + foreach ($this->param['data'] as $k => $v){ | ||
| 234 | + if(!empty($v) && is_array($v)){ | ||
| 235 | + foreach ($v as $text => $translate){ | ||
| 236 | + $data[$text] = $translate; | ||
| 237 | + } | ||
| 236 | } | 238 | } |
| 237 | } | 239 | } |
| 238 | } | 240 | } |
| 1 | <?php | 1 | <?php |
| 2 | /** | 2 | /** |
| 3 | * @remark : | 3 | * @remark : |
| 4 | - * @name :PromotionKeyword.php | 4 | + * @name :KeywordVideoTask.php |
| 5 | * @author :lyh | 5 | * @author :lyh |
| 6 | * @method :post | 6 | * @method :post |
| 7 | * @time :2024/2/26 9:33 | 7 | * @time :2024/2/26 9:33 |
| @@ -11,7 +11,10 @@ namespace App\Models\Com; | @@ -11,7 +11,10 @@ namespace App\Models\Com; | ||
| 11 | 11 | ||
| 12 | use App\Models\Base; | 12 | use App\Models\Base; |
| 13 | 13 | ||
| 14 | -class PromotionKeyword extends Base | 14 | +class KeywordVideoTask extends Base |
| 15 | { | 15 | { |
| 16 | - protected $table = 'gl_promotion_keyword'; | 16 | + const STATUS_OPEN = 0; |
| 17 | + const STATUS_CLOSE = 1;//停止 | ||
| 18 | + | ||
| 19 | + protected $table = 'gl_promotion_keyword_task'; | ||
| 17 | } | 20 | } |
app/Models/Com/KeywordVideoTaskLog.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :KeywordVideoTask.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2024/2/26 9:33 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Models\Com; | ||
| 11 | + | ||
| 12 | +use App\Models\Base; | ||
| 13 | + | ||
| 14 | +class KeywordVideoTaskLog extends Base | ||
| 15 | +{ | ||
| 16 | + const STATUS_INIT = 0; | ||
| 17 | + const STATUS_RUNING = 0; | ||
| 18 | + | ||
| 19 | + protected $table = 'gl_keyword_video_task_log'; | ||
| 20 | +} |
| @@ -329,10 +329,10 @@ Route::middleware(['aloginauth'])->group(function () { | @@ -329,10 +329,10 @@ Route::middleware(['aloginauth'])->group(function () { | ||
| 329 | /** | 329 | /** |
| 330 | * 生成视频的项目 | 330 | * 生成视频的项目 |
| 331 | */ | 331 | */ |
| 332 | - Route::prefix('promotion_keyword')->group(function () { | ||
| 333 | - Route::any('/', [Aside\Com\KeywordController::class, 'lists'])->name('promotion_keyword_lists'); | ||
| 334 | - Route::any('/createKeywordTask', [Aside\Com\KeywordController::class, 'createKeywordTask'])->name('promotion_keyword_createKeywordTask'); | ||
| 335 | - Route::any('/edit', [Aside\Com\KeywordController::class, 'edit'])->name('promotion_keyword_edit'); | 332 | + Route::prefix('keyword_video')->group(function () { |
| 333 | + Route::any('/', [Aside\Com\KeywordVideoController::class, 'lists'])->name('promotion_keyword_lists'); | ||
| 334 | + Route::any('/createKeywordTask', [Aside\Com\KeywordVideoController::class, 'createKeywordTask'])->name('promotion_keyword_createKeywordTask'); | ||
| 335 | + Route::any('/edit', [Aside\Com\KeywordVideoController::class, 'edit'])->name('promotion_keyword_edit'); | ||
| 336 | }); | 336 | }); |
| 337 | 337 | ||
| 338 | // 公共主题模版 | 338 | // 公共主题模版 |
-
请 注册 或 登录 后发表评论