作者 刘锟

Merge remote-tracking branch 'origin/master' into akun

@@ -43,6 +43,7 @@ class RankData extends BaseCommands @@ -43,6 +43,7 @@ class RankData extends BaseCommands
43 */ 43 */
44 public function do() 44 public function do()
45 { 45 {
  46 + Log::channel('rank_data')->info('开始-排名数据');
46 //同步api_no 47 //同步api_no
47 $this->SyncApiNo(); 48 $this->SyncApiNo();
48 49
@@ -103,4 +103,21 @@ class IndexController extends BaseController @@ -103,4 +103,21 @@ class IndexController extends BaseController
103 } 103 }
104 $this->response('success'); 104 $this->response('success');
105 } 105 }
  106 +
  107 + /**
  108 + * 生成嵌套AICC企微的token
  109 + * @author zbj
  110 + * @date 2024/2/29
  111 + */
  112 + public function generateAiCCToken(){
  113 + $data = [
  114 + 'id' => $this->manage['id'],
  115 + 'name' => $this->manage['name'],
  116 + 'timestamp' => time(), // 接收到字符串解密出来以后需要 验证时间不超过30秒 超过时间视为无效授权
  117 + ];
  118 + $common = new \App\Helper\Common();
  119 + $str = $common->encrypt($data);
  120 + $this->response('success',Code::SUCCESS,['str'=>$str]);
  121 + }
  122 +
106 } 123 }
@@ -12,6 +12,7 @@ namespace App\Http\Controllers\Aside\Com; @@ -12,6 +12,7 @@ namespace App\Http\Controllers\Aside\Com;
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\KeywordVideoTask; 14 use App\Models\Com\KeywordVideoTask;
  15 +use App\Models\Com\KeywordVideoTaskLog;
15 use App\Models\Domain\DomainInfo; 16 use App\Models\Domain\DomainInfo;
16 use App\Models\Project\Project; 17 use App\Models\Project\Project;
17 18
@@ -125,4 +126,23 @@ class KeywordVideoController extends BaseController @@ -125,4 +126,23 @@ class KeywordVideoController extends BaseController
125 } 126 }
126 $this->response('success'); 127 $this->response('success');
127 } 128 }
  129 +
  130 + /**
  131 + * @remark :记录
  132 + * @name :getVideoTaskLog
  133 + * @author :lyh
  134 + * @method :post
  135 + * @time :2024/3/1 16:40
  136 + */
  137 + public function getVideoTaskLog(){
  138 + $this->request->validate([
  139 + 'project_id'=>'required',
  140 + ], [
  141 + 'project_id.required' => '项目唯一标识不为空',
  142 + ]);
  143 + $taskLogModel = new KeywordVideoTaskLog();
  144 + $list = $taskLogModel->lists($this->map,$this->page,$this->row);
  145 + $this->response('success',Code::SUCCESS,$list);
  146 + }
  147 +
128 } 148 }
@@ -324,4 +324,31 @@ class ComController extends BaseController @@ -324,4 +324,31 @@ class ComController extends BaseController
324 Cache::add('login-project-'.$this->user['mobile'],1,300); 324 Cache::add('login-project-'.$this->user['mobile'],1,300);
325 $this->response('success',Code::SUCCESS,$data); 325 $this->response('success',Code::SUCCESS,$data);
326 } 326 }
  327 +
  328 + /**
  329 + * @remark :推荐采购商
  330 + * @name :recommendedPurchaser
  331 + * @author :lyh
  332 + * @method :post
  333 + * @time :2024/3/4 10:10
  334 + */
  335 + public function recommendedPurchaser(){
  336 + $this->param['keyword'] = 'led';
  337 + $url = 'https://admin.hagro.cn/api/company_list';
  338 + $data = [
  339 + 'prod_desc'=>$this->param['keyword'],
  340 + 'total'=>$this->param['now'] ?? 10,
  341 + ];
  342 + @file_put_contents(storage_path('logs/lyh_error.log'), var_export(http_build_query($data), true) . PHP_EOL, FILE_APPEND);
  343 + $token = 'company_list'.date('Y-m-d').http_build_query(arsort($data));
  344 + @file_put_contents(storage_path('logs/lyh_error.log'), var_export($token, true) . PHP_EOL, FILE_APPEND);
  345 + $param = [
  346 + 'prod_desc'=>$this->param['keyword'],
  347 + 'token'=>$token,
  348 + 'total'=>$this->param['now'] ?? 10,
  349 + ];
  350 + $lists = http_post($url,$param);
  351 + @file_put_contents(storage_path('logs/lyh_error.log'), var_export($token, true) . PHP_EOL, FILE_APPEND);
  352 + $this->response('success',Code::SUCCESS,$lists);
  353 + }
327 } 354 }
@@ -427,9 +427,8 @@ class RankDataLogic extends BaseLogic @@ -427,9 +427,8 @@ class RankDataLogic extends BaseLogic
427 427
428 $first_num = $first_page_num = $first_three_pages_num = $first_five_pages_num = $first_ten_pages_num = 0; 428 $first_num = $first_page_num = $first_three_pages_num = $first_five_pages_num = $first_ten_pages_num = 0;
429 429
430 - if(!$lang){  
431 - foreach ($data as &$ranks){  
432 - ksort($ranks); 430 + foreach ($data as &$ranks){
  431 + ksort($ranks);
433 // foreach ($ranks as &$rank){ 432 // foreach ($ranks as &$rank){
434 // //处理排名 433 // //处理排名
435 // if(!in_array($project_id, $without_project_ids)){ 434 // if(!in_array($project_id, $without_project_ids)){
@@ -439,30 +438,30 @@ class RankDataLogic extends BaseLogic @@ -439,30 +438,30 @@ class RankDataLogic extends BaseLogic
439 // //todo 需要特殊处理排名的项目 438 // //todo 需要特殊处理排名的项目
440 // } 439 // }
441 // } 440 // }
442 - $last = Arr::last($ranks);  
443 - //第一名  
444 - if($last['position'] == 1){  
445 - $first_num ++;  
446 - }  
447 - //排名第一页  
448 - if($last['position'] > 0 && $last['position'] <= 10){  
449 - $first_page_num ++;  
450 - }  
451 - //排名前三页  
452 - if($last['position'] > 0 && $last['position'] <= 30){  
453 - $first_three_pages_num ++;  
454 - }  
455 - //排名前五页  
456 - if($last['position'] > 0 && $last['position'] <= 50){  
457 - $first_five_pages_num ++;  
458 - }  
459 - //排名前十页  
460 - if($last['position'] > 0 && $last['position'] <= 100){  
461 - $first_ten_pages_num ++;  
462 - } 441 + $last = Arr::last($ranks);
  442 + //第一名
  443 + if($last['position'] == 1){
  444 + $first_num ++;
  445 + }
  446 + //排名第一页
  447 + if($last['position'] > 0 && $last['position'] <= 10){
  448 + $first_page_num ++;
  449 + }
  450 + //排名前三页
  451 + if($last['position'] > 0 && $last['position'] <= 30){
  452 + $first_three_pages_num ++;
  453 + }
  454 + //排名前五页
  455 + if($last['position'] > 0 && $last['position'] <= 50){
  456 + $first_five_pages_num ++;
  457 + }
  458 + //排名前十页
  459 + if($last['position'] > 0 && $last['position'] <= 100){
  460 + $first_ten_pages_num ++;
463 } 461 }
464 } 462 }
465 463
  464 +
466 $where = [ 465 $where = [
467 'project_id' => $project_id, 466 'project_id' => $project_id,
468 'lang' => $lang 467 'lang' => $lang
@@ -473,12 +472,12 @@ class RankDataLogic extends BaseLogic @@ -473,12 +472,12 @@ class RankDataLogic extends BaseLogic
473 } 472 }
474 473
475 //关键词达标天数 474 //关键词达标天数
476 - $model->is_compliance = 0;  
477 - if($model->updated_date != date('Y-m-d')){ 475 + if($model->updated_date != date('Y-m-d') || empty($model->is_compliance)){
478 //保证关键词数 476 //保证关键词数
479 $keyword_num = DeployBuild::where('project_id', $project_id)->value('keyword_num'); 477 $keyword_num = DeployBuild::where('project_id', $project_id)->value('keyword_num');
480 $type = Project::where('id', $project_id)->value('type'); 478 $type = Project::where('id', $project_id)->value('type');
481 if($keyword_num && $type == Project::TYPE_TWO && $first_page_num >= $keyword_num){ 479 if($keyword_num && $type == Project::TYPE_TWO && $first_page_num >= $keyword_num){
  480 + Log::channel('rank_data')->info('项目'.$project_id.':关键词达标-'.$first_page_num);
482 $model->compliance_day = $model->compliance_day + 1; 481 $model->compliance_day = $model->compliance_day + 1;
483 $model->is_compliance = 1; 482 $model->is_compliance = 1;
484 //项目表更新 483 //项目表更新
@@ -486,6 +485,8 @@ class RankDataLogic extends BaseLogic @@ -486,6 +485,8 @@ class RankDataLogic extends BaseLogic
486 $compliance_day = Project::where(['id' => $project_id])->value('finish_remain_day') ?: 0; 485 $compliance_day = Project::where(['id' => $project_id])->value('finish_remain_day') ?: 0;
487 Project::where('id', $project_id)->update(['is_remain_today' => 1, 'finish_remain_day' => $compliance_day+1]); 486 Project::where('id', $project_id)->update(['is_remain_today' => 1, 'finish_remain_day' => $compliance_day+1]);
488 } 487 }
  488 + }else{
  489 + Log::channel('rank_data')->info('项目'.$project_id.':关键词未达标-'.$first_page_num);
489 } 490 }
490 } 491 }
491 $model->project_id = $project_id; 492 $model->project_id = $project_id;
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :PurchaserJob.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/3/4 11:06
  8 + */
  9 +
  10 +namespace App\Jobs;
  11 +
  12 +use Illuminate\Bus\Queueable;
  13 +use Illuminate\Contracts\Queue\ShouldQueue;
  14 +use Illuminate\Foundation\Bus\Dispatchable;
  15 +use Illuminate\Queue\InteractsWithQueue;
  16 +use Illuminate\Queue\SerializesModels;
  17 +
  18 +class PurchaserJob implements ShouldQueue
  19 +{
  20 + use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  21 + public $tries = 3; // 可配置任务重试次数
  22 +
  23 + protected $param;
  24 +
  25 + /**
  26 + * Create a new job instance.
  27 + *
  28 + * @param CopyImageFile $event
  29 + * @return void
  30 + */
  31 + public function __construct($data)
  32 + {
  33 + $this->param = $data;
  34 + }
  35 +
  36 + /**
  37 + * Handle the event.
  38 + *
  39 + * @param UpdateHtml $event
  40 + * @return void
  41 + */
  42 + public function handle()
  43 + {
  44 +
  45 + }
  46 +}
@@ -336,9 +336,10 @@ Route::middleware(['aloginauth'])->group(function () { @@ -336,9 +336,10 @@ Route::middleware(['aloginauth'])->group(function () {
336 * 生成视频的项目 336 * 生成视频的项目
337 */ 337 */
338 Route::prefix('keyword_video')->group(function () { 338 Route::prefix('keyword_video')->group(function () {
339 - Route::any('/', [Aside\Com\KeywordVideoController::class, 'lists'])->name('promotion_keyword_lists');  
340 - Route::any('/createKeywordTask', [Aside\Com\KeywordVideoController::class, 'createKeywordTask'])->name('promotion_keyword_createKeywordTask');  
341 - Route::any('/edit', [Aside\Com\KeywordVideoController::class, 'edit'])->name('promotion_keyword_edit'); 339 + Route::any('/', [Aside\Com\KeywordVideoController::class, 'lists'])->name('keyword_video_lists');
  340 + Route::any('/createKeywordTask', [Aside\Com\KeywordVideoController::class, 'createKeywordTask'])->name('keyword_video_createKeywordTask');
  341 + Route::any('/edit', [Aside\Com\KeywordVideoController::class, 'edit'])->name('keyword_video_edit');
  342 + Route::any('/getVideoTaskLog', [Aside\Com\KeywordVideoController::class, 'getVideoTaskLog'])->name('keyword_video_getVideoTaskLog');
342 }); 343 });
343 344
344 // 公共主题模版 345 // 公共主题模版
@@ -371,6 +372,9 @@ Route::middleware(['aloginauth'])->group(function () { @@ -371,6 +372,9 @@ Route::middleware(['aloginauth'])->group(function () {
371 Route::any('/del', [Aside\Template\ATemplateTypeController::class, 'del'])->name('admin.ATemplateType_del'); 372 Route::any('/del', [Aside\Template\ATemplateTypeController::class, 'del'])->name('admin.ATemplateType_del');
372 }); 373 });
373 }); 374 });
  375 +
  376 +
  377 + Route::any('/generate_aicc_token', [Aside\Com\IndexController::class, 'generateAiCCToken'])->name('admin.generate_aicc_token');
374 }); 378 });
375 379
376 //无需登录验证的路由组 380 //无需登录验证的路由组
@@ -20,6 +20,7 @@ Route::middleware(['bloginauth'])->group(function () { @@ -20,6 +20,7 @@ Route::middleware(['bloginauth'])->group(function () {
20 Route::any('/generateToken', [\App\Http\Controllers\Bside\BCom\ComController::class, 'generateToken'])->name('generateToken'); 20 Route::any('/generateToken', [\App\Http\Controllers\Bside\BCom\ComController::class, 'generateToken'])->name('generateToken');
21 Route::any('/getLink', [\App\Http\Controllers\Bside\BCom\ComController::class, 'getLink'])->name('getLink'); 21 Route::any('/getLink', [\App\Http\Controllers\Bside\BCom\ComController::class, 'getLink'])->name('getLink');
22 Route::any('/getMobileProject', [\App\Http\Controllers\Bside\BCom\ComController::class, 'getMobileProject'])->name('getMobileProject'); 22 Route::any('/getMobileProject', [\App\Http\Controllers\Bside\BCom\ComController::class, 'getMobileProject'])->name('getMobileProject');
  23 + Route::any('/recommendedPurchaser', [\App\Http\Controllers\Bside\BCom\ComController::class, 'recommendedPurchaser'])->name('recommendedPurchaser');
23 //用户相关路由 24 //用户相关路由
24 Route::prefix('user')->group(function () { 25 Route::prefix('user')->group(function () {
25 Route::any('/', [\App\Http\Controllers\Bside\User\UserController::class, 'lists'])->name('user_lists'); 26 Route::any('/', [\App\Http\Controllers\Bside\User\UserController::class, 'lists'])->name('user_lists');