正在显示
3 个修改的文件
包含
105 行增加
和
1 行删除
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :GeoQuestionResult.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2025/7/3 15:13 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Console\Commands\Geo; | ||
| 11 | + | ||
| 12 | +use App\Models\Geo\GeoQuestion; | ||
| 13 | +use Illuminate\Console\Command; | ||
| 14 | +use Illuminate\Support\Facades\Redis; | ||
| 15 | + | ||
| 16 | +class GeoQuestionResult extends Command | ||
| 17 | +{ | ||
| 18 | + /** | ||
| 19 | + * The name and signature of the console command. | ||
| 20 | + * | ||
| 21 | + * @var string | ||
| 22 | + */ | ||
| 23 | + protected $signature = 'geo_question_result'; | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * The console command description. | ||
| 27 | + * | ||
| 28 | + * @var string | ||
| 29 | + */ | ||
| 30 | + protected $description = 'geo设置请求获取结果'; | ||
| 31 | + | ||
| 32 | + public function handle(){ | ||
| 33 | + $task_id = $this->getTaskId(); | ||
| 34 | + dd($task_id); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + /** | ||
| 38 | + * @remark :拉取任务id | ||
| 39 | + * @name :getTaskId | ||
| 40 | + * @author :lyh | ||
| 41 | + * @method :post | ||
| 42 | + * @time :2025/7/3 15:15 | ||
| 43 | + */ | ||
| 44 | + public function getTaskId(){ | ||
| 45 | + $task_id = Redis::rpop('geo_question_result'); | ||
| 46 | + if(empty($task_id)){ | ||
| 47 | + $questionModel = new GeoQuestion(); | ||
| 48 | + $ids = $questionModel->selectField(['status'=>1,'next_time'=>['<=',date('Y-m-d')]],'id'); | ||
| 49 | + if(!empty($ids)){ | ||
| 50 | + foreach ($ids as $id) { | ||
| 51 | + Redis::lpush('geo_question_result', $id); | ||
| 52 | + } | ||
| 53 | + } | ||
| 54 | + $task_id = Redis::rpop('ai_blog_task'); | ||
| 55 | + } | ||
| 56 | + return $task_id; | ||
| 57 | + } | ||
| 58 | +} |
| @@ -86,7 +86,7 @@ class GeoLogic extends BaseLogic | @@ -86,7 +86,7 @@ class GeoLogic extends BaseLogic | ||
| 86 | $this->param['url'] = json_encode($this->param['url'] ?? [],true); | 86 | $this->param['url'] = json_encode($this->param['url'] ?? [],true); |
| 87 | $this->param['keywords'] = json_encode($this->param['keywords'] ?? [],true); | 87 | $this->param['keywords'] = json_encode($this->param['keywords'] ?? [],true); |
| 88 | //执行时间设置为今天 | 88 | //执行时间设置为今天 |
| 89 | - $this->param['current_time'] = date('Y-m-d'); | 89 | + $this->param['next_time'] = date('Y-m-d'); |
| 90 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 90 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 91 | $id = $this->param['id']; | 91 | $id = $this->param['id']; |
| 92 | $this->model->edit($this->param,['id'=>$id]); | 92 | $this->model->edit($this->param,['id'=>$id]); |
app/Services/Geo/GeoService.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :GeoService.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2025/7/3 14:21 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Services\Geo; | ||
| 11 | + | ||
| 12 | +class GeoService | ||
| 13 | +{ | ||
| 14 | + public $api_key = '7yn!We6$&NnVA38bpGy*A@4TQ5iYLJcW'; | ||
| 15 | + | ||
| 16 | + public $api_url = 'https://api.cmer.com/'; | ||
| 17 | + /** | ||
| 18 | + * @remark :请求的方法 | ||
| 19 | + * @name :requestAction | ||
| 20 | + * @author :lyh | ||
| 21 | + * @method :post | ||
| 22 | + * @time :2025/7/3 14:26 | ||
| 23 | + */ | ||
| 24 | + public function webSearchChatAction($content,$platform){ | ||
| 25 | + $route = 'v1/websearch_chat'; | ||
| 26 | + $url = $this->api_url.$route; | ||
| 27 | + $header = [ | ||
| 28 | + 'accept: application/json', | ||
| 29 | + 'X-CmerApi-Host: llm-chat.p.cmer.com', | ||
| 30 | + 'apikey: '.$this->api_key, | ||
| 31 | + 'Content-Type: application/json' | ||
| 32 | + ]; | ||
| 33 | + $message = [ | ||
| 34 | + 'messages'=>[ | ||
| 35 | + [ | ||
| 36 | + 'content'=>$content, | ||
| 37 | + 'role'=>'user' | ||
| 38 | + ], | ||
| 39 | + 'platform'=>$platform, | ||
| 40 | + 'security_check'=>true | ||
| 41 | + ], | ||
| 42 | + ]; | ||
| 43 | + $data = http_post($url,json_encode($message,true),$header); | ||
| 44 | + return $data; | ||
| 45 | + } | ||
| 46 | +} |
-
请 注册 或 登录 后发表评论