Merge remote-tracking branch 'origin/master' into akun
正在显示
15 个修改的文件
包含
248 行增加
和
110 行删除
| @@ -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 |
| @@ -9,11 +9,16 @@ namespace App\Console\Commands\KeywordInVideo; | @@ -9,11 +9,16 @@ namespace App\Console\Commands\KeywordInVideo; | ||
| 9 | 9 | ||
| 10 | use App\Console\Commands\Model; | 10 | use App\Console\Commands\Model; |
| 11 | use App\Console\Commands\TaskSub; | 11 | use App\Console\Commands\TaskSub; |
| 12 | +use App\Enums\Common\Code; | ||
| 12 | use App\Models\Com\KeywordVideoTask; | 13 | use App\Models\Com\KeywordVideoTask; |
| 13 | use App\Models\Com\KeywordVideoTaskLog; | 14 | use App\Models\Com\KeywordVideoTaskLog; |
| 15 | +use App\Models\Domain\DomainInfo; | ||
| 14 | use App\Models\Product\Keyword; | 16 | use App\Models\Product\Keyword; |
| 17 | +use App\Models\Product\Product; | ||
| 18 | +use App\Models\RouteMap\RouteMap; | ||
| 15 | use App\Services\ProjectServer; | 19 | use App\Services\ProjectServer; |
| 16 | use Illuminate\Console\Command; | 20 | use Illuminate\Console\Command; |
| 21 | +use Illuminate\Support\Facades\DB; | ||
| 17 | use Illuminate\Support\Facades\Http; | 22 | use Illuminate\Support\Facades\Http; |
| 18 | use Illuminate\Support\Facades\Log; | 23 | use Illuminate\Support\Facades\Log; |
| 19 | 24 | ||
| @@ -89,11 +94,12 @@ class VideoTask extends Command | @@ -89,11 +94,12 @@ class VideoTask extends Command | ||
| 89 | if ($log){ | 94 | if ($log){ |
| 90 | continue; | 95 | continue; |
| 91 | } | 96 | } |
| 97 | + $keywordInfo = $this->getKeywordImage($val->id,$task_project->project_id); | ||
| 92 | $array = [ | 98 | $array = [ |
| 93 | 'project_id' => $task_project->project_id, | 99 | 'project_id' => $task_project->project_id, |
| 94 | 'keyword_id' => $val->id, | 100 | 'keyword_id' => $val->id, |
| 95 | 'keyword' => $val->title, | 101 | 'keyword' => $val->title, |
| 96 | - 'data' => json_encode(['url' => '', 'description' => '', 'images' => [], 'keywords' => []]), | 102 | + 'data' => json_encode(['url' => $keywordInfo['url'],'title' => $keywordInfo['title'], 'description' => $keywordInfo['keyword_content'], 'images' => $keywordInfo['product_list'], 'keywords' => $keywordInfo['keyword_list']]), |
| 97 | 'status' => KeywordVideoTaskLog::STATUS_INIT, | 103 | 'status' => KeywordVideoTaskLog::STATUS_INIT, |
| 98 | 'updated_at' => date('Y-m-d H:i:s'), | 104 | 'updated_at' => date('Y-m-d H:i:s'), |
| 99 | 'created_at' => date('Y-m-d H:i:s'), | 105 | 'created_at' => date('Y-m-d H:i:s'), |
| @@ -113,26 +119,26 @@ class VideoTask extends Command | @@ -113,26 +119,26 @@ class VideoTask extends Command | ||
| 113 | */ | 119 | */ |
| 114 | public function sendSubTask() | 120 | public function sendSubTask() |
| 115 | { | 121 | { |
| 116 | - $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(); |
| 117 | if ($subTask->isEmpty()) | 123 | if ($subTask->isEmpty()) |
| 118 | return true; | 124 | return true; |
| 119 | foreach ($subTask as $val) { | 125 | foreach ($subTask as $val) { |
| 126 | + $valData = json_decode($val->data); | ||
| 120 | $task_id = 'v6-' . uniqid(); | 127 | $task_id = 'v6-' . uniqid(); |
| 121 | $data = [ | 128 | $data = [ |
| 122 | 'project_data' => [ | 129 | 'project_data' => [ |
| 123 | - 'tag_url' => '', | ||
| 124 | - 'title' => '', | ||
| 125 | - 'keywords' => [], | ||
| 126 | - 'description' => '', | ||
| 127 | - 'images' => '' | 130 | + 'tag_url' => $valData['url'], |
| 131 | + 'title' => $valData['title'], | ||
| 132 | + 'keywords' => $valData['keywords'], | ||
| 133 | + 'description' => $valData['description'], | ||
| 134 | + 'images' => $valData['images'] | ||
| 128 | ], | 135 | ], |
| 129 | 'task_id' => $task_id, | 136 | 'task_id' => $task_id, |
| 130 | - 'callback_url' => '', | 137 | + 'callback_url' => env('APP_URL') . '/api/video_task_callback', |
| 131 | ]; | 138 | ]; |
| 132 | $result = Http::post('http://216.250.255.116:7866/create_task', $data); | 139 | $result = Http::post('http://216.250.255.116:7866/create_task', $data); |
| 133 | - | ||
| 134 | $val->task_id = $task_id; | 140 | $val->task_id = $task_id; |
| 135 | - $val->status = STATUS_RUNING::STATUS_RUNING; | 141 | + $val->status = KeywordVideoTaskLog::STATUS_RUNNING; |
| 136 | $val->request_result = $result; | 142 | $val->request_result = $result; |
| 137 | $val->save(); | 143 | $val->save(); |
| 138 | } | 144 | } |
| @@ -159,4 +165,68 @@ class VideoTask extends Command | @@ -159,4 +165,68 @@ class VideoTask extends Command | ||
| 159 | $project_id = 110; | 165 | $project_id = 110; |
| 160 | return $project_id; | 166 | return $project_id; |
| 161 | } | 167 | } |
| 168 | + | ||
| 169 | + /** | ||
| 170 | + * @remark :根据关键字获取产品主图 | ||
| 171 | + * @name :getKeywordList | ||
| 172 | + * @author :lyh | ||
| 173 | + * @method :post | ||
| 174 | + * @time :2024/2/23 16:28 | ||
| 175 | + */ | ||
| 176 | + public function getKeywordImage($keyword_id,$project_id){ | ||
| 177 | + $keywordModel = new Keyword(); | ||
| 178 | + $keywordInfo = $keywordModel->read(['id'=>$keyword_id]); | ||
| 179 | + //TODO::所有产品 | ||
| 180 | + $thumb = $this->getRecommendAndHotProducts($keywordInfo['route'],$project_id); | ||
| 181 | + $domainModel = new DomainInfo(); | ||
| 182 | + $domainInfo = $domainModel->read(['project_id'=>$project_id]); | ||
| 183 | + if(!empty($domainInfo)){ | ||
| 184 | + $keywordInfo['route'] = $domainInfo['domain'].'/'.$keywordInfo['route']; | ||
| 185 | + } | ||
| 186 | + $keyword_arr = Keyword::where("project_id",$project_id)->where("status",1)->inRandomOrder()->take(10)->pluck('title')->toArray();; | ||
| 187 | + $data = [ | ||
| 188 | + 'url'=>$keywordInfo['route'], | ||
| 189 | + 'title'=>$keywordInfo['title'], | ||
| 190 | + 'keyword_title'=>$keywordInfo['keyword_title'], | ||
| 191 | + 'keyword_content'=>$keywordInfo['keyword_content'], | ||
| 192 | + 'product_list'=>$thumb ?? [], | ||
| 193 | + 'keyword_list'=>$keyword_arr ?? [] | ||
| 194 | + ]; | ||
| 195 | + return $data; | ||
| 196 | + } | ||
| 197 | + | ||
| 198 | + /** | ||
| 199 | + * 关键词聚合页-推荐&热门产品 | ||
| 200 | + */ | ||
| 201 | + public function getRecommendAndHotProducts($route,$project_id): ?array | ||
| 202 | + { | ||
| 203 | + $productIds = []; | ||
| 204 | + $productKeyword = Keyword::where("project_id",$project_id)->where("route",$route)->first(); | ||
| 205 | + if (!empty($productKeyword)){ | ||
| 206 | + $productsQuery = Product::where("project_id", $project_id)->where("status",1)->where("keyword_id","like","%,".$productKeyword->id.",%")->limit(7)->get(); | ||
| 207 | + if (!empty($productsQuery)){ | ||
| 208 | + foreach ($productsQuery as $item){ | ||
| 209 | + $productIds[] = $item->id; | ||
| 210 | + } | ||
| 211 | + if (count($productIds)<7){ | ||
| 212 | + $randomData = Product::where("project_id", $project_id)->where("status",1)->whereNotIn('id', $productIds)->inRandomOrder()->take(13-count($productIds))->get(); | ||
| 213 | + $products = $productsQuery->merge($randomData); | ||
| 214 | + }else{ | ||
| 215 | + $products = $productsQuery; | ||
| 216 | + } | ||
| 217 | + }else{ | ||
| 218 | + $products = Product::where("project_id", $project_id)->where("status",1)->inRandomOrder()->take(13)->get(); | ||
| 219 | + } | ||
| 220 | + } | ||
| 221 | + $data = []; | ||
| 222 | + if (!empty($products)){ | ||
| 223 | + foreach ($products as $item){ | ||
| 224 | + $data[] = !empty($item->thumb) && $item->thumb['url'] != "" ? getImageUrl($item->thumb['url']) : ""; | ||
| 225 | + } | ||
| 226 | + } | ||
| 227 | + return $data; | ||
| 228 | + } | ||
| 229 | + | ||
| 230 | + | ||
| 231 | + | ||
| 162 | } | 232 | } |
| @@ -64,10 +64,11 @@ class RankData extends BaseCommands | @@ -64,10 +64,11 @@ class RankData extends BaseCommands | ||
| 64 | return false; | 64 | return false; |
| 65 | } | 65 | } |
| 66 | foreach ($list as $item){ | 66 | foreach ($list as $item){ |
| 67 | + echo $item['api_no'] . PHP_EOL; | ||
| 67 | try { | 68 | try { |
| 68 | (new RankDataLogic())->syncRankData($item['api_no'], $site_res); | 69 | (new RankDataLogic())->syncRankData($item['api_no'], $site_res); |
| 69 | }catch (\Exception $e){ | 70 | }catch (\Exception $e){ |
| 70 | - Log::channel('rank_data')->error('RankData:失败 ' . $e->getMessage()); | 71 | + Log::channel('rank_data')->error('RankData:失败 ' . $item['api_no'] . $e->getMessage()); |
| 71 | $error++; | 72 | $error++; |
| 72 | continue; | 73 | continue; |
| 73 | } | 74 | } |
| @@ -16,6 +16,8 @@ use App\Models\Manage\BelongingGroup; | @@ -16,6 +16,8 @@ use App\Models\Manage\BelongingGroup; | ||
| 16 | use App\Models\Manage\Dept; | 16 | use App\Models\Manage\Dept; |
| 17 | use App\Models\Manage\EntryPosition; | 17 | use App\Models\Manage\EntryPosition; |
| 18 | use App\Models\Manage\ManageHr; | 18 | use App\Models\Manage\ManageHr; |
| 19 | +use App\Models\Product\Keyword; | ||
| 20 | +use App\Models\Product\Product; | ||
| 19 | use App\Models\Project\Project; | 21 | use App\Models\Project\Project; |
| 20 | use App\Models\WebSetting\WebSettingService; | 22 | use App\Models\WebSetting\WebSettingService; |
| 21 | use App\Services\ProjectServer; | 23 | use App\Services\ProjectServer; |
| @@ -260,17 +262,73 @@ class Demo extends Command | @@ -260,17 +262,73 @@ class Demo extends Command | ||
| 260 | // } | 262 | // } |
| 261 | 263 | ||
| 262 | public function handle(){ | 264 | public function handle(){ |
| 263 | - $projectModel = new Project(); | ||
| 264 | - $list = $projectModel->list(['delete_status'=>0]); | ||
| 265 | - foreach ($list as $v){ | ||
| 266 | - ProjectServer::useProject($v['id']); | ||
| 267 | - $webSettingServiceModel = new WebSettingService(); | ||
| 268 | - $info = $webSettingServiceModel->read(['values'=>['like','%+86%']]); | ||
| 269 | - if($info !== false){ | ||
| 270 | - echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; | ||
| 271 | - } | 265 | +// $projectModel = new Project(); |
| 266 | +// $list = $projectModel->list(['delete_status'=>0]); | ||
| 267 | +// foreach ($list as $v){ | ||
| 268 | + ProjectServer::useProject(150); | ||
| 269 | + $this->getKeywordImage(); | ||
| 272 | DB::disconnect('custom_mysql'); | 270 | DB::disconnect('custom_mysql'); |
| 271 | +// } | ||
| 272 | + } | ||
| 273 | + | ||
| 274 | + /** | ||
| 275 | + * @remark :根据关键字获取产品主图 | ||
| 276 | + * @name :getKeywordList | ||
| 277 | + * @author :lyh | ||
| 278 | + * @method :post | ||
| 279 | + * @time :2024/2/23 16:28 | ||
| 280 | + */ | ||
| 281 | + public function getKeywordImage($keyword_id = 1,$project_id = 150){ | ||
| 282 | + $keywordModel = new Keyword(); | ||
| 283 | + $keywordInfo = $keywordModel->read(['id'=>$keyword_id]); | ||
| 284 | + //TODO::所有产品 | ||
| 285 | + $thumb = $this->getRecommendAndHotProducts($keywordInfo['route'],$project_id); | ||
| 286 | + $domainModel = new DomainInfo(); | ||
| 287 | + $domainInfo = $domainModel->read(['project_id'=>$project_id]); | ||
| 288 | + if(!empty($domainInfo)){ | ||
| 289 | + $keywordInfo['route'] = $domainInfo['domain'].'/'.$keywordInfo['route']; | ||
| 290 | + } | ||
| 291 | + $data = [ | ||
| 292 | + 'url'=>$keywordInfo['route'], | ||
| 293 | + 'title'=>$keywordInfo['title'], | ||
| 294 | + 'keyword_title'=>$keywordInfo['keyword_title'], | ||
| 295 | + 'keyword_content'=>$keywordInfo['keyword_content'], | ||
| 296 | + 'product_list'=>$thumb ?? [] | ||
| 297 | + ]; | ||
| 298 | + dd($data); | ||
| 299 | + return $data; | ||
| 300 | + } | ||
| 301 | + | ||
| 302 | + /** | ||
| 303 | + * 关键词聚合页-推荐&热门产品 | ||
| 304 | + */ | ||
| 305 | + public function getRecommendAndHotProducts($route,$project_id): ?array | ||
| 306 | + { | ||
| 307 | + $productIds = []; | ||
| 308 | + $productKeyword = Keyword::where("project_id",$project_id)->where("route",$route)->first(); | ||
| 309 | + if (!empty($productKeyword)){ | ||
| 310 | + $productsQuery = Product::where("project_id", $project_id)->where("status",1)->where("keyword_id","like","%,".$productKeyword->id.",%")->limit(7)->get(); | ||
| 311 | + if (!empty($productsQuery)){ | ||
| 312 | + foreach ($productsQuery as $item){ | ||
| 313 | + $productIds[] = $item->id; | ||
| 314 | + } | ||
| 315 | + if (count($productIds)<7){ | ||
| 316 | + $randomData = Product::where("project_id", $project_id)->where("status",1)->whereNotIn('id', $productIds)->inRandomOrder()->take(13-count($productIds))->get(); | ||
| 317 | + $products = $productsQuery->merge($randomData); | ||
| 318 | + }else{ | ||
| 319 | + $products = $productsQuery; | ||
| 320 | + } | ||
| 321 | + }else{ | ||
| 322 | + $products = Product::where("project_id", $project_id)->where("status",1)->inRandomOrder()->take(13)->get(); | ||
| 323 | + } | ||
| 324 | + } | ||
| 325 | + $data = []; | ||
| 326 | + if (!empty($products)){ | ||
| 327 | + foreach ($products as $item){ | ||
| 328 | + $data[] = !empty($item->thumb) && $item->thumb['url'] != "" ? getImageUrl($item->thumb['url']) : ""; | ||
| 329 | + } | ||
| 273 | } | 330 | } |
| 331 | + return $data; | ||
| 274 | } | 332 | } |
| 275 | public function printMessage() | 333 | public function printMessage() |
| 276 | { | 334 | { |
| @@ -75,13 +75,13 @@ class QuanqiusouApi | @@ -75,13 +75,13 @@ class QuanqiusouApi | ||
| 75 | /** | 75 | /** |
| 76 | * 获取谷歌排名数据 | 76 | * 获取谷歌排名数据 |
| 77 | * @param $api_no | 77 | * @param $api_no |
| 78 | - * @param int $lang | 78 | + * @param string $lang |
| 79 | * @param int $day | 79 | * @param int $day |
| 80 | * @return array|false|mixed | 80 | * @return array|false|mixed |
| 81 | * @author zbj | 81 | * @author zbj |
| 82 | * @date 2023/5/11 | 82 | * @date 2023/5/11 |
| 83 | */ | 83 | */ |
| 84 | - public function getGoogleRank($api_no, int $lang = 0, int $day = 7, $force = true) | 84 | + public function getGoogleRank($api_no, string $lang = '', int $day = 7, $force = true) |
| 85 | { | 85 | { |
| 86 | $key = "quanqiusou_api_rank_{$api_no}_{$lang}_{$day}_" . date('Y-m-d'); | 86 | $key = "quanqiusou_api_rank_{$api_no}_{$lang}_{$day}_" . date('Y-m-d'); |
| 87 | $res = Cache::get($key); | 87 | $res = Cache::get($key); |
| @@ -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,46 @@ class NoticeController extends BaseController | @@ -58,4 +62,46 @@ 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('callback_resource'); | ||
| 78 | + $embed_code = $request->input('embed_code'); | ||
| 79 | + $all = $request->all(); | ||
| 80 | + // 获取子任务 | ||
| 81 | + $log = KeywordVideoTaskLog::where(['task_id' => $task_id])->first(); | ||
| 82 | + if (empty($log)){ | ||
| 83 | + return 200; | ||
| 84 | + } | ||
| 85 | + // 更新子任务状态 更新任务信息 | ||
| 86 | + $log->status = KeywordVideoTaskLog::STATUS_FINISH; | ||
| 87 | + $log->result_status = $status; | ||
| 88 | + $log->result_info = json_encode($all); | ||
| 89 | + $log->save(); | ||
| 90 | + if ($status != 200) { | ||
| 91 | + return 200; | ||
| 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 | + } | ||
| 100 | + $keyword->video = $video; | ||
| 101 | + $keyword->embed_code = $embed_code; | ||
| 102 | + $keyword->video_thumb = $thumb; | ||
| 103 | + $keyword->save(); | ||
| 104 | + DB::disconnect('custom_mysql'); | ||
| 105 | + return 200; | ||
| 106 | + } | ||
| 61 | } | 107 | } |
| @@ -17,6 +17,7 @@ use App\Services\ProjectServer; | @@ -17,6 +17,7 @@ use App\Services\ProjectServer; | ||
| 17 | use Illuminate\Support\Facades\Cache; | 17 | use Illuminate\Support\Facades\Cache; |
| 18 | use Illuminate\Support\Facades\DB; | 18 | use Illuminate\Support\Facades\DB; |
| 19 | use Illuminate\Support\Facades\Hash; | 19 | use Illuminate\Support\Facades\Hash; |
| 20 | +use Illuminate\Support\Facades\Log; | ||
| 20 | 21 | ||
| 21 | /** | 22 | /** |
| 22 | * Class IndexController | 23 | * Class IndexController |
| @@ -102,60 +103,4 @@ class IndexController extends BaseController | @@ -102,60 +103,4 @@ class IndexController extends BaseController | ||
| 102 | } | 103 | } |
| 103 | $this->response('success'); | 104 | $this->response('success'); |
| 104 | } | 105 | } |
| 105 | - | ||
| 106 | - /** | ||
| 107 | - * @remark :根据关键字获取产品主图 | ||
| 108 | - * @name :getKeywordList | ||
| 109 | - * @author :lyh | ||
| 110 | - * @method :post | ||
| 111 | - * @time :2024/2/23 16:28 | ||
| 112 | - */ | ||
| 113 | - public function getKeywordImage(){ | ||
| 114 | - $arr = explode('/',trim(str_replace('https://', '', $this->param['url']),'/')); | ||
| 115 | - if(empty($arr) || !is_array($arr)){ | ||
| 116 | - $this->response('当前项目不存在..',Code::SYSTEM_ERROR); | ||
| 117 | - } | ||
| 118 | - $domainModel = new DomainInfo(); | ||
| 119 | - $domainInfo = $domainModel->read(['domain'=>$arr[0]]); | ||
| 120 | - if($domainInfo === false){ | ||
| 121 | - $this->response('当前项目不存在.',Code::SYSTEM_ERROR); | ||
| 122 | - } | ||
| 123 | - ProjectServer::useProject($domainInfo['project_id']); | ||
| 124 | - $routeMapModel = new RouteMap(); | ||
| 125 | - $routeInfo = $routeMapModel->read(['route'=>$arr[1]]); | ||
| 126 | - if($domainInfo === false){ | ||
| 127 | - $this->response('当前路由不存在.',Code::SYSTEM_ERROR); | ||
| 128 | - } | ||
| 129 | - $keywordModel = new Keyword(); | ||
| 130 | - $keywordInfo = $keywordModel->read(['id'=>$routeInfo['source_id']]); | ||
| 131 | - $count = Product::where('keyword_id','like' ,'%,'.$keywordInfo['id'].',%')->count(); | ||
| 132 | - $productModel = new Product(); | ||
| 133 | - if($count < 5){ | ||
| 134 | - $productList = $productModel->list([],'sort',['thumb','title']); | ||
| 135 | - //获取7个产品主图 | ||
| 136 | - }else{ | ||
| 137 | - $productList = $productModel->list(['keyword_id'=>['like','%,'.$keywordInfo['id'].',%']],['thumb','title']); | ||
| 138 | - } | ||
| 139 | - $product_image = []; | ||
| 140 | - foreach ($productList as $k => $v){ | ||
| 141 | - $image = []; | ||
| 142 | - if(!empty($v['thumb']) && !empty($v['thumb']['url'])){ | ||
| 143 | - $image['image'] = getImageUrl($v['thumb']['url']); | ||
| 144 | - $image['title'] = $v['title']; | ||
| 145 | - $product_image[] = $image; | ||
| 146 | - } | ||
| 147 | - if(count($product_image) > 6){ | ||
| 148 | - break; | ||
| 149 | - } | ||
| 150 | - } | ||
| 151 | - $data = [ | ||
| 152 | - 'title'=>$keywordInfo['title'], | ||
| 153 | - 'keyword_title'=>$keywordInfo['keyword_title'], | ||
| 154 | - 'keyword_content'=>$keywordInfo['keyword_content'], | ||
| 155 | - 'product_list'=>$product_image | ||
| 156 | - ]; | ||
| 157 | - DB::disconnect('custom_mysql'); | ||
| 158 | - $this->response('success',Code::SUCCESS,$data); | ||
| 159 | - } | ||
| 160 | - | ||
| 161 | } | 106 | } |
| @@ -7,6 +7,8 @@ use App\Enums\Common\Code; | @@ -7,6 +7,8 @@ use App\Enums\Common\Code; | ||
| 7 | use App\Http\Logic\Aside\LoginLogic; | 7 | use App\Http\Logic\Aside\LoginLogic; |
| 8 | use App\Models\Domain\DomainInfo; | 8 | use App\Models\Domain\DomainInfo; |
| 9 | use App\Models\Manage\Manage; | 9 | use App\Models\Manage\Manage; |
| 10 | +use App\Models\Product\Keyword; | ||
| 11 | +use App\Models\Product\Product; | ||
| 10 | use App\Models\Project\Project; | 12 | use App\Models\Project\Project; |
| 11 | use App\Models\Sms\SmsLog; | 13 | use App\Models\Sms\SmsLog; |
| 12 | use App\Rules\Mobile; | 14 | use App\Rules\Mobile; |
| @@ -82,16 +82,26 @@ class CreateKeywordLogic extends BaseLogic | @@ -82,16 +82,26 @@ class CreateKeywordLogic extends BaseLogic | ||
| 82 | if(empty($this->param['keyword'])){ | 82 | if(empty($this->param['keyword'])){ |
| 83 | return $this->success($data); | 83 | return $this->success($data); |
| 84 | } | 84 | } |
| 85 | - $prefix_keyword = $this->prefixKeyword($this->param['prefix'] ?? [],$this->param['keyword']); | ||
| 86 | - $keyword_suffix = $this->keywordSuffix($this->param['suffix'] ?? [],$this->param['keyword']); | ||
| 87 | - $prefix_keyword_suffix = $this->prefixKeywordSuffix($this->param['prefix'] ?? [],$this->param['suffix'] ?? [],$this->param['keyword']); | 85 | + $except_k = ['Quality','Philippines','USA','UK','America','China','Wholesale','Hot Sale','Cheap','cheap','price','pricelist','hot sale','Price','Pricelist','With ','For ','And ','Oem','Odm','Supplier','Manufacturer','CE Certification','Factory','Exporters','Company','Companies','Suppliers','Manufacturers','Factories','Company','Companies','Exporters','Exporter','Buy ',' Buy','Where ','What ','When ','How ','Which ','Producer','Producers','Best Selling','Hot Selling','Near','Chinese','India','use','high quality','discount','online','custom','customized','Enterprise','Agent','Plant','Refinery','Foundry','Maker','Distributor']; |
| 86 | + $filterKeywords = []; | ||
| 87 | + foreach ($this->param['keyword'] as $k=>$v){ | ||
| 88 | + if(in_array($v,$except_k)){ | ||
| 89 | + unset($this->param['keyword'][$k]); | ||
| 90 | + $filterKeywords[] = $v; | ||
| 91 | + } | ||
| 92 | + } | ||
| 93 | + $prefix_keyword = $this->prefixKeyword($this->param['prefix'] ?? [],$this->param['keyword'],$except_k); | ||
| 94 | + $keyword_suffix = $this->keywordSuffix($this->param['suffix'] ?? [],$this->param['keyword'],$except_k); | ||
| 95 | + $prefix_keyword_suffix = $this->prefixKeywordSuffix($this->param['prefix'] ?? [],$this->param['suffix'] ?? [],$this->param['keyword'],$except_k); | ||
| 88 | $data = [ | 96 | $data = [ |
| 89 | 'prefix_keyword'=>$prefix_keyword, | 97 | 'prefix_keyword'=>$prefix_keyword, |
| 90 | 'prefix_keyword_count'=>count($prefix_keyword), | 98 | 'prefix_keyword_count'=>count($prefix_keyword), |
| 91 | 'keyword_suffix'=>$keyword_suffix, | 99 | 'keyword_suffix'=>$keyword_suffix, |
| 92 | 'keyword_suffix_count'=>count($keyword_suffix), | 100 | 'keyword_suffix_count'=>count($keyword_suffix), |
| 93 | 'prefix_keyword_suffix'=>$prefix_keyword_suffix, | 101 | 'prefix_keyword_suffix'=>$prefix_keyword_suffix, |
| 94 | - 'prefix_keyword_suffix_count'=>count($prefix_keyword_suffix) | 102 | + 'prefix_keyword_suffix_count'=>count($prefix_keyword_suffix), |
| 103 | + 'filterKeywords'=>$filterKeywords, | ||
| 104 | + 'filterKeywords_count'=>count($filterKeywords), | ||
| 95 | ]; | 105 | ]; |
| 96 | return $this->success($data); | 106 | return $this->success($data); |
| 97 | } | 107 | } |
| @@ -103,7 +113,7 @@ class CreateKeywordLogic extends BaseLogic | @@ -103,7 +113,7 @@ class CreateKeywordLogic extends BaseLogic | ||
| 103 | * @method :post | 113 | * @method :post |
| 104 | * @time :2023/12/19 11:11 | 114 | * @time :2023/12/19 11:11 |
| 105 | */ | 115 | */ |
| 106 | - public function prefixKeyword($prefix,$keyword){ | 116 | + public function prefixKeyword($prefix,$keyword,$except_k){ |
| 107 | $prefix_keyword = array(); | 117 | $prefix_keyword = array(); |
| 108 | if(!empty($prefix)){//前缀+关键词 | 118 | if(!empty($prefix)){//前缀+关键词 |
| 109 | foreach ($keyword as $keywordItem){ | 119 | foreach ($keyword as $keywordItem){ |
| @@ -96,7 +96,9 @@ class CountLogic extends BaseLogic | @@ -96,7 +96,9 @@ class CountLogic extends BaseLogic | ||
| 96 | ]; | 96 | ]; |
| 97 | $data = $rankDataModel->read($param,['first_num','first_page_num','first_three_pages_num','first_five_pages_num','first_ten_pages_num']); | 97 | $data = $rankDataModel->read($param,['first_num','first_page_num','first_three_pages_num','first_five_pages_num','first_ten_pages_num']); |
| 98 | if($data === false){ | 98 | if($data === false){ |
| 99 | - $param['updated_date'] = Carbon::yesterday()->toDateString(); | 99 | + $param = [ |
| 100 | + 'project_id' => $this->user['project_id'] | ||
| 101 | + ]; | ||
| 100 | $data = $rankDataModel->read($param,['first_num','first_page_num','first_three_pages_num','first_five_pages_num','first_ten_pages_num']); | 102 | $data = $rankDataModel->read($param,['first_num','first_page_num','first_three_pages_num','first_five_pages_num','first_ten_pages_num']); |
| 101 | if($data === false){ | 103 | if($data === false){ |
| 102 | $data = []; | 104 | $data = []; |
| @@ -379,7 +379,7 @@ class RankDataLogic extends BaseLogic | @@ -379,7 +379,7 @@ class RankDataLogic extends BaseLogic | ||
| 379 | 379 | ||
| 380 | $model = RankData::where('project_id', $project_id)->where('lang', '')->first(); | 380 | $model = RankData::where('project_id', $project_id)->where('lang', '')->first(); |
| 381 | if (!$model || $model->updated_date != date('Y-m-d') || $force) { | 381 | if (!$model || $model->updated_date != date('Y-m-d') || $force) { |
| 382 | - $res = $api->getGoogleRank($api_no, 0, 7, $force); | 382 | + $res = $api->getGoogleRank($api_no, '', 7, $force); |
| 383 | if (!$res) { | 383 | if (!$res) { |
| 384 | throw new \Exception("接口数据获取失败,api_no:{$api_no}"); | 384 | throw new \Exception("接口数据获取失败,api_no:{$api_no}"); |
| 385 | } | 385 | } |
| @@ -390,19 +390,21 @@ class RankDataLogic extends BaseLogic | @@ -390,19 +390,21 @@ class RankDataLogic extends BaseLogic | ||
| 390 | //有小语种的 | 390 | //有小语种的 |
| 391 | $lang_list = $api->getLangList(); | 391 | $lang_list = $api->getLangList(); |
| 392 | if (!empty($lang_list[$api_no])) { | 392 | if (!empty($lang_list[$api_no])) { |
| 393 | - $model = RankData::where('project_id', $project_id)->where('lang', '<>', '')->first(); | ||
| 394 | - if (!$model || $model->updated_date != date('Y-m-d') || $force) { | ||
| 395 | - $res = $api->getGoogleRank($api_no, $model->lang, 7, $force); | ||
| 396 | - if (!$res) { | ||
| 397 | - throw new \Exception("接口数据获取失败,api_no:{$api_no},lang"); | ||
| 398 | - } | ||
| 399 | - $data = []; | ||
| 400 | - //不同的小语种取出来 | ||
| 401 | - foreach ($res as $keyword => $v) { | ||
| 402 | - $data[Arr::last($v)['lang']][$keyword] = $v; | ||
| 403 | - } | ||
| 404 | - foreach ($data as $lang => $rank) { | ||
| 405 | - $this->save_rank($project_id, $rank, 0, $lang); | 393 | + foreach ($lang_list[$api_no] as $lang){ |
| 394 | + $model = RankData::where('project_id', $project_id)->where('lang', $lang)->first(); | ||
| 395 | + if (!$model || $model->updated_date != date('Y-m-d') || $force) { | ||
| 396 | + $res = $api->getGoogleRank($api_no, $lang, 7, $force); | ||
| 397 | + if (!$res) { | ||
| 398 | + throw new \Exception("接口数据获取失败,api_no:{$api_no},lang"); | ||
| 399 | + } | ||
| 400 | + $data = []; | ||
| 401 | + //不同的小语种取出来 | ||
| 402 | + foreach ($res as $keyword => $v) { | ||
| 403 | + $data[Arr::last($v)['lang']][$keyword] = $v; | ||
| 404 | + } | ||
| 405 | + foreach ($data as $lang => $rank) { | ||
| 406 | + $this->save_rank($project_id, $rank, 0, $lang); | ||
| 407 | + } | ||
| 406 | } | 408 | } |
| 407 | } | 409 | } |
| 408 | } | 410 | } |
| @@ -426,15 +428,15 @@ class RankDataLogic extends BaseLogic | @@ -426,15 +428,15 @@ class RankDataLogic extends BaseLogic | ||
| 426 | if(!$lang){ | 428 | if(!$lang){ |
| 427 | foreach ($data as &$ranks){ | 429 | foreach ($data as &$ranks){ |
| 428 | ksort($ranks); | 430 | ksort($ranks); |
| 429 | - foreach ($ranks as &$rank){ | ||
| 430 | - //处理排名 | ||
| 431 | - if(!in_array($project_id, $without_project_ids)){ | ||
| 432 | - if($rank['position'] >= 10){ | ||
| 433 | - $rank['position'] -= 5; | ||
| 434 | - } | ||
| 435 | - //todo 需要特殊处理排名的项目 | ||
| 436 | - } | ||
| 437 | - } | 431 | +// foreach ($ranks as &$rank){ |
| 432 | +// //处理排名 | ||
| 433 | +// if(!in_array($project_id, $without_project_ids)){ | ||
| 434 | +// if($rank['position'] >= 10){ | ||
| 435 | +// $rank['position'] -= 5; | ||
| 436 | +// } | ||
| 437 | +// //todo 需要特殊处理排名的项目 | ||
| 438 | +// } | ||
| 439 | +// } | ||
| 438 | $last = Arr::last($ranks); | 440 | $last = Arr::last($ranks); |
| 439 | //第一名 | 441 | //第一名 |
| 440 | if($last['position'] == 1){ | 442 | if($last['position'] == 1){ |
| @@ -16,5 +16,5 @@ class KeywordVideoTask extends Base | @@ -16,5 +16,5 @@ class KeywordVideoTask extends Base | ||
| 16 | const STATUS_OPEN = 0; | 16 | const STATUS_OPEN = 0; |
| 17 | const STATUS_CLOSE = 1;//停止 | 17 | const STATUS_CLOSE = 1;//停止 |
| 18 | 18 | ||
| 19 | - protected $table = 'gl_promotion_keyword_task'; | 19 | + protected $table = 'gl_keyword_video_task'; |
| 20 | } | 20 | } |
| @@ -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 = 0; | 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'); |
| @@ -389,7 +389,6 @@ Route::group([], function () { | @@ -389,7 +389,6 @@ Route::group([], function () { | ||
| 389 | Route::any('/collect', [Aside\Collect\CollectController::class, 'index'])->name('admin.collect'); | 389 | Route::any('/collect', [Aside\Collect\CollectController::class, 'index'])->name('admin.collect'); |
| 390 | //同步询盘 | 390 | //同步询盘 |
| 391 | Route::any('/sync_inquiry', [Aside\Com\IndexController::class, 'sync_inquiry'])->name('admin.sync_inquiry'); | 391 | Route::any('/sync_inquiry', [Aside\Com\IndexController::class, 'sync_inquiry'])->name('admin.sync_inquiry'); |
| 392 | - Route::any('/getKeywordImage', [Aside\Com\IndexController::class, 'getKeywordImage'])->name('admin.getKeywordImage'); | ||
| 393 | }); | 392 | }); |
| 394 | 393 | ||
| 395 | 394 |
-
请 注册 或 登录 后发表评论