作者 lyh

GX生成白帽报表脚本

<?php
/**
* @remark :
* @name :GeoQuestionResult.php
* @author :lyh
* @method :post
* @time :2025/7/3 15:13
*/
namespace App\Console\Commands\Geo;
use App\Models\Geo\GeoQuestion;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Redis;
class GeoQuestionResult extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'geo_question_result';
/**
* The console command description.
*
* @var string
*/
protected $description = 'geo设置请求获取结果';
public function handle(){
$task_id = $this->getTaskId();
dd($task_id);
}
/**
* @remark :拉取任务id
* @name :getTaskId
* @author :lyh
* @method :post
* @time :2025/7/3 15:15
*/
public function getTaskId(){
$task_id = Redis::rpop('geo_question_result');
if(empty($task_id)){
$questionModel = new GeoQuestion();
$ids = $questionModel->selectField(['status'=>1,'next_time'=>['<=',date('Y-m-d')]],'id');
if(!empty($ids)){
foreach ($ids as $id) {
Redis::lpush('geo_question_result', $id);
}
}
$task_id = Redis::rpop('ai_blog_task');
}
return $task_id;
}
}
... ...
... ... @@ -86,7 +86,7 @@ class GeoLogic extends BaseLogic
$this->param['url'] = json_encode($this->param['url'] ?? [],true);
$this->param['keywords'] = json_encode($this->param['keywords'] ?? [],true);
//执行时间设置为今天
$this->param['current_time'] = date('Y-m-d');
$this->param['next_time'] = date('Y-m-d');
if(isset($this->param['id']) && !empty($this->param['id'])){
$id = $this->param['id'];
$this->model->edit($this->param,['id'=>$id]);
... ...
<?php
/**
* @remark :
* @name :GeoService.php
* @author :lyh
* @method :post
* @time :2025/7/3 14:21
*/
namespace App\Services\Geo;
class GeoService
{
public $api_key = '7yn!We6$&NnVA38bpGy*A@4TQ5iYLJcW';
public $api_url = 'https://api.cmer.com/';
/**
* @remark :请求的方法
* @name :requestAction
* @author :lyh
* @method :post
* @time :2025/7/3 14:26
*/
public function webSearchChatAction($content,$platform){
$route = 'v1/websearch_chat';
$url = $this->api_url.$route;
$header = [
'accept: application/json',
'X-CmerApi-Host: llm-chat.p.cmer.com',
'apikey: '.$this->api_key,
'Content-Type: application/json'
];
$message = [
'messages'=>[
[
'content'=>$content,
'role'=>'user'
],
'platform'=>$platform,
'security_check'=>true
],
];
$data = http_post($url,json_encode($message,true),$header);
return $data;
}
}
... ...