作者 李宇航

合并分支 'lyh-server' 到 'master'

Lyh server



查看合并请求 !2263
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :GeoQuestionResController.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\GeoPlatform;
  13 +use App\Models\Geo\GeoQuestion;
  14 +use App\Models\Geo\GeoQuestionLog;
  15 +use App\Models\Geo\GeoQuestionResult;
  16 +use App\Models\Project\Project;
  17 +use App\Services\Geo\GeoService;
  18 +use Illuminate\Console\Command;
  19 +use Illuminate\Support\Facades\Redis;
  20 +
  21 +class GeoQuestionRes extends Command
  22 +{
  23 + /**
  24 + * The name and signature of the console command.
  25 + *
  26 + * @var string
  27 + */
  28 + protected $signature = 'geo_question_result';
  29 +
  30 + /**
  31 + * The console command description.
  32 + *
  33 + * @var string
  34 + */
  35 + protected $description = 'geo设置请求获取结果';
  36 +
  37 + public function handle(){
  38 + while (true){
  39 + $task_id = $this->getTaskId();
  40 + if(empty($task_id)){
  41 + echo '无数据'.PHP_EOL;
  42 + sleep(30);
  43 + continue;
  44 + }
  45 + $questionModel = new GeoQuestion();//问题
  46 + $info = $questionModel->read(['id'=>$task_id]);
  47 + //获取当前项目的执行频率
  48 + $projectModel = new Project();
  49 + $projectInfo = $projectModel->read(['id'=>$info['project_id']],['geo_status','geo_frequency']);
  50 + if($projectInfo['geo_status'] == 0){
  51 + $questionModel->edit(['status'=>0],['id'=>$task_id]);
  52 + continue;
  53 + }
  54 + $questionArr = $info['question'];
  55 + if(empty($questionArr)){
  56 + echo date('Y-m-d H:i:s').'当前任务不存在问题。'.PHP_EOL;
  57 + $questionModel->edit(['status'=>0],['id'=>$task_id]);
  58 + }
  59 + //获取平台信息
  60 + $platformModel = new GeoPlatform();//平台
  61 + $platformArr = $platformModel->selectField(['status'=>$platformModel::STATUS_ON],'en_name');
  62 + if(empty($platformArr)){
  63 + echo date('Y-m-d H:i:s').'请求平台为空。'.PHP_EOL;
  64 + continue;
  65 + }
  66 + $geoService = new GeoService();
  67 + $keywordArr = $info['keywords'] ?? [];
  68 + $urlArr = $info['url'] ?? [];
  69 + $geoResultModel = new GeoQuestionResult();
  70 + foreach ($questionArr as $q_item){
  71 + foreach ($platformArr as $p_item){
  72 + $keywords = [];//命中的关键词
  73 + $urls = [];//命中的网址
  74 + try {
  75 + $result_data = $geoService->setWebSearchChatAction($q_item,$p_item);
  76 + echo 'success:'.$result_data['code'].PHP_EOL;
  77 + if(isset($result_data) && $result_data['code'] == 200){
  78 + $keywords = $this->getKeywords($keywordArr,$result_data['text'] ?? []);
  79 + $urls = $this->getUrl($urlArr,$result_data['annotations'] ?? []);
  80 + }
  81 + }catch (\Exception $e){
  82 + echo $e->getMessage().PHP_EOL;
  83 + continue;
  84 + }
  85 + //查询当前是否已有执行保存记录
  86 + $resultInfo = $geoResultModel->read(['project_id'=>$info['project_id'],'question_id'=>$info['id'],'platform'=>$p_item,'question'=>$q_item],['id']);
  87 + //保存一条结果记录
  88 + $data = [
  89 + 'project_id'=>$info['project_id'],
  90 + 'question_id'=>$info['id'],
  91 + 'platform'=>$p_item,
  92 + 'question'=>$q_item,
  93 + 'keywords'=>json_encode($keywords ?? [],true),//命中的关键词
  94 + 'text'=>json_encode($result_data ?? [],true),
  95 + 'url'=>json_encode($urls ?? [],true),//命中的网址
  96 + 'type'=>$info['type'] ?? 1
  97 + ];
  98 + if($resultInfo === false){
  99 + $geoResultModel->addReturnId($data);
  100 + }else{
  101 + $geoResultModel->edit($data,['id'=>$resultInfo['id']]);
  102 + }
  103 + $data_log = [
  104 + 'project_id'=>$info['project_id'],
  105 + 'question_id'=>$info['id'],
  106 + 'platform'=>$p_item,
  107 + 'question'=>$q_item,
  108 + 'text'=>json_encode($result_data ?? [],true),
  109 + 'type'=>$info['type'] ?? 1
  110 + ];
  111 + $geoLogModel = new GeoQuestionLog();
  112 + $geoLogModel->addReturnId($data_log);
  113 + }
  114 + }
  115 + //更新下次执行时间
  116 + $questionModel->edit(['current_time'=>date('Y-m-d'),'next_time'=>date('Y-m-d', strtotime(date('Y-m-d') . ' +'.(int)$projectInfo['geo_frequency'].' days'))],['id'=>$info['id']]);
  117 + }
  118 + }
  119 +
  120 + /**
  121 + * @remark :获取命中的url
  122 + * @name :getUrl
  123 + * @author :lyh
  124 + * @method :post
  125 + * @time :2025/7/3 16:38
  126 + */
  127 + public function getUrl($urlArr = [],$result_annotations = [],$result_text = []){
  128 + $url = [];
  129 + if(!empty($urlArr)){
  130 + foreach ($urlArr as $u_item){
  131 + if(!empty($result_text)){
  132 + if (str_contains($result_text, $u_item)) {
  133 + $url[] = $u_item;
  134 + }
  135 + }
  136 + if(!empty($result_annotations)){
  137 + foreach ($result_annotations as $a_item){
  138 + echo 'url'.$a_item['url_citation']['url'].PHP_EOL.'当前的url:'.$u_item;
  139 + if (str_contains($a_item['url_citation']['url'], $u_item)) {
  140 + $url[] = $u_item;
  141 + }
  142 + }
  143 + }
  144 + }
  145 + }
  146 + return array_values(array_unique($url));
  147 + }
  148 +
  149 + /**
  150 + * @remark :获取命中的关键词
  151 + * @name :getKeywords
  152 + * @author :lyh
  153 + * @method :post
  154 + * @time :2025/7/3 16:26
  155 + */
  156 + public function getKeywords($keywordArr = [],$result_text = []){
  157 + $keywords = [];
  158 + if(!empty($keywordArr) && !empty($result_text)){
  159 + foreach ($keywordArr as $k_item){
  160 + if (str_contains($result_text, $k_item)) {
  161 + $keywords[] = $k_item;
  162 + }
  163 + }
  164 + }
  165 + return $keywords;
  166 + }
  167 +
  168 + /**
  169 + * @remark :拉取任务id
  170 + * @name :getTaskId
  171 + * @author :lyh
  172 + * @method :post
  173 + * @time :2025/7/3 15:15
  174 + */
  175 + public function getTaskId(){
  176 + $task_id = Redis::rpop('geo_question_result');
  177 + if(empty($task_id)){
  178 + $questionModel = new GeoQuestion();
  179 + $ids = $questionModel->selectField(['status'=>1,'next_time'=>['<=',date('Y-m-d')]],'id');
  180 + if(!empty($ids)){
  181 + foreach ($ids as $id) {
  182 + Redis::lpush('geo_question_result', $id);
  183 + }
  184 + }
  185 + $task_id = Redis::rpop('geo_question_result');
  186 + }
  187 + return $task_id;
  188 + }
  189 +}
@@ -59,7 +59,11 @@ class GeneratePage extends Command @@ -59,7 +59,11 @@ class GeneratePage extends Command
59 $noticeInfo = $noticeModel->read(['id'=>$task_id]); 59 $noticeInfo = $noticeModel->read(['id'=>$task_id]);
60 try { 60 try {
61 $this->output(' taskID: ' . $noticeInfo['id'] . ' start'); 61 $this->output(' taskID: ' . $noticeInfo['id'] . ' start');
  62 + if(!is_array($noticeInfo['data'])){
62 $notice_data = json_decode($noticeInfo['data'],true); 63 $notice_data = json_decode($noticeInfo['data'],true);
  64 + }else{
  65 + $notice_data = $noticeInfo['data'];
  66 + }
63 $c_url = $notice_data['c_url']; 67 $c_url = $notice_data['c_url'];
64 $c_params = json_encode($notice_data['c_params']); 68 $c_params = json_encode($notice_data['c_params']);
65 $re = http_post($c_url, $c_params, [], true); 69 $re = http_post($c_url, $c_params, [], true);
@@ -19,14 +19,12 @@ use App\Models\News\NewsCategory; @@ -19,14 +19,12 @@ use App\Models\News\NewsCategory;
19 use App\Models\Product\Category; 19 use App\Models\Product\Category;
20 use App\Models\Product\Keyword; 20 use App\Models\Product\Keyword;
21 use App\Models\Product\Product; 21 use App\Models\Product\Product;
22 -use App\Models\Project\Project;  
23 use App\Models\RouteMap\RouteMap; 22 use App\Models\RouteMap\RouteMap;
24 use App\Services\ProjectServer; 23 use App\Services\ProjectServer;
25 use Illuminate\Console\Command; 24 use Illuminate\Console\Command;
26 use Illuminate\Support\Facades\DB; 25 use Illuminate\Support\Facades\DB;
27 use Illuminate\Support\Facades\Redis; 26 use Illuminate\Support\Facades\Redis;
28 use PhpOffice\PhpSpreadsheet\IOFactory; 27 use PhpOffice\PhpSpreadsheet\IOFactory;
29 -use function Aws\default_http_handler;  
30 28
31 class UpdateProjectTdk extends Command 29 class UpdateProjectTdk extends Command
32 { 30 {
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :GeoQuestionController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/7/2 17:42
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Aside\Geo;
  11 +
  12 +use App\Enums\Common\Code;
  13 +use App\Http\Controllers\Aside\BaseController;
  14 +use App\Http\Logic\Aside\Geo\GeoLogic;
  15 +use Illuminate\Http\Request;
  16 +
  17 +/**
  18 + * @remark :项目geo设置
  19 + * @name :GeoQuestionController
  20 + * @author :lyh
  21 + * @method :post
  22 + * @time :2025/7/2 17:42
  23 + */
  24 +class GeoQuestionController extends BaseController
  25 +{
  26 + public function __construct(Request $request)
  27 + {
  28 + parent::__construct($request);
  29 + $this->logic = new GeoLogic();
  30 + }
  31 +
  32 + /**
  33 + * @remark :开启或关闭geo设置
  34 + * @name :setGeoStatus
  35 + * @author :lyh
  36 + * @method :post
  37 + * @time :2025/7/2 17:50
  38 + */
  39 + public function setGeoStatus(){
  40 + $this->request->validate([
  41 + 'project_id'=>'required',
  42 + 'geo_status'=>'required',
  43 + 'geo_frequency'=>'required',
  44 + ],[
  45 + 'project_id.required' => '项目ID不能为空',
  46 + 'geo_status.required' => '项目开启与关闭不能为空',
  47 + 'geo_frequency.required' => '项目发送频率不能为空',
  48 + ]);
  49 + $data = $this->logic->setGeoStatus();
  50 + $this->response('success',Code::SUCCESS,$data);
  51 + }
  52 +
  53 + /**
  54 + * @remark :获取类型
  55 + * @name :getType
  56 + * @author :lyh
  57 + * @method :post
  58 + * @time :2025/7/3 10:46
  59 + */
  60 + public function getType(){
  61 + $data = $this->logic->getType();
  62 + $this->response('success',Code::SUCCESS,$data);
  63 + }
  64 +
  65 + /**
  66 + * @remark :问题列表
  67 + * @name :getGeoQuestion
  68 + * @author :lyh
  69 + * @method :post
  70 + * @time :2025/7/3 9:09
  71 + */
  72 + public function getGeoQuestionList(){
  73 + $this->request->validate([
  74 + 'project_id'=>'required',
  75 + ],[
  76 + 'project_id.required' => '项目ID不能为空',
  77 + ]);
  78 + $data = $this->logic->getGeoQuestionList($this->map,$this->page,$this->row,$this->order);
  79 + $this->response('success',Code::SUCCESS,$data);
  80 + }
  81 +
  82 + /**
  83 + * @remark :保存问题数据
  84 + * @name :saveGeoQuestion
  85 + * @author :lyh
  86 + * @method :post
  87 + * @time :2025/7/3 9:31
  88 + * @param : question->提交的问题
  89 + * @param : url->提交的网址
  90 + * @param : keywords->提交的关键字
  91 + * @param : status->状态(0:可执行 1:禁止执行)
  92 + * @param : project_id->项目id
  93 + * @param : type->类型(1:品牌 2:营销)
  94 + */
  95 + public function saveGeoQuestion(){
  96 + $this->request->validate([
  97 + 'project_id'=>'required',
  98 + 'question'=>'required',
  99 + 'keywords'=>'required',
  100 + 'url'=>'required',
  101 + 'status'=>'required',
  102 + 'type'=>'required',
  103 + ],[
  104 + 'project_id.required' => '项目ID不能为空',
  105 + 'question.required' => '项目ID不能为空',
  106 + 'keywords.required' => '项目ID不能为空',
  107 + 'url.required' => '项目ID不能为空',
  108 + 'status.required' => '项目ID不能为空',
  109 + 'type.required' => '类型不能为空',
  110 + ]);
  111 + $data = $this->logic->saveGeoQuestion();
  112 + $this->response('success',Code::SUCCESS,$data);
  113 + }
  114 +
  115 + /**
  116 + * @remark :删除问题
  117 + * @name :del
  118 + * @author :lyh
  119 + * @method :post
  120 + * @time :2025/7/3 10:11
  121 + * @param :id->主键
  122 + */
  123 + public function delGeoQuestion(){
  124 + $this->request->validate([
  125 + 'ids'=>'required|array',
  126 + ],[
  127 + 'ids.required' => 'ID集合不能为空',
  128 + 'ids.array' => 'ID集合为数组',
  129 + ]);
  130 + $data = $this->logic->delGeoQuestion();
  131 + $this->response('success',Code::SUCCESS,$data);
  132 + }
  133 +}
@@ -58,8 +58,20 @@ class ComController extends BaseController @@ -58,8 +58,20 @@ class ComController extends BaseController
58 public function seo_get_menu(){ 58 public function seo_get_menu(){
59 $seoMenuModel = new ProjectMenuSeo(); 59 $seoMenuModel = new ProjectMenuSeo();
60 $this->map['status'] = 0; 60 $this->map['status'] = 0;
  61 + $data = [];
  62 + $is_ai_blog = $this->getIsAiBlog();
  63 + if($is_ai_blog != 1){
  64 + $data[] = 57;
  65 + }
  66 + $is_ai_video = $this->getIsAiVideo();
  67 + if($is_ai_video != 1){
  68 + $data[] = 74;
  69 + }
61 if($this->user['login_source'] == User::LOGIN_PASSWORD_SOURCE){ 70 if($this->user['login_source'] == User::LOGIN_PASSWORD_SOURCE){
62 - $this->map['id'] = ['not in',[19]]; 71 + $data[] = 19;
  72 + }
  73 + if(!empty($data)){
  74 + $this->map['id'] = ['not in',$data];
63 } 75 }
64 $lists = $seoMenuModel->list($this->map,'sort'); 76 $lists = $seoMenuModel->list($this->map,'sort');
65 $menu = array(); 77 $menu = array();
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :GeoQuestionResController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/7/4 9:37
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Bside\Geo;
  11 +
  12 +use App\Enums\Common\Code;
  13 +use App\Http\Controllers\Bside\BaseController;
  14 +use App\Http\Logic\Bside\Geo\GeoQuestionResLogic;
  15 +use Illuminate\Http\Request;
  16 +
  17 +/**
  18 + * @remark :请求数据结果
  19 + * @name :GeoQuestionResController
  20 + * @author :lyh
  21 + * @method :post
  22 + * @time :2025/7/4 9:37
  23 + */
  24 +class GeoQuestionResController extends BaseController
  25 +{
  26 + public function __construct(Request $request)
  27 + {
  28 + parent::__construct($request);
  29 + $this->logic = new GeoQuestionResLogic();
  30 + }
  31 +
  32 + /**
  33 + * @remark :获取列表数据
  34 + * @name :getList
  35 + * @author :lyh
  36 + * @method :post
  37 + * @time :2025/7/4 9:38
  38 + */
  39 + public function getList(){
  40 + $this->request->validate([
  41 + 'project_id'=>'required',
  42 + 'type'=>'required'
  43 + ],[
  44 + 'project_id.required' => 'project_id不能为空',
  45 + 'type.required' => '品牌类型不能为空'
  46 + ]);
  47 + $data = $this->logic->getResultList($this->map,$this->page,$this->row,$this->order);
  48 + $this->response('success',Code::SUCCESS,$data);
  49 + }
  50 +
  51 + /**
  52 + * @remark :
  53 + * @name :getInfo
  54 + * @author :lyh
  55 + * @method :post
  56 + * @time :2025/7/4 9:38
  57 + */
  58 + public function getInfo(){
  59 + $this->request->validate([
  60 + 'id'=>'required',
  61 + ],[
  62 + 'id.required' => 'id不能为空',
  63 + ]);
  64 + $data = $this->logic->getResultInfo();
  65 + $this->response('success',Code::SUCCESS,$data);
  66 + }
  67 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :GeoLogic.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/7/2 17:51
  8 + */
  9 +
  10 +namespace App\Http\Logic\Aside\Geo;
  11 +
  12 +use App\Http\Logic\Aside\BaseLogic;
  13 +use App\Models\Geo\GeoPlatform;
  14 +use App\Models\Geo\GeoQuestion;
  15 +use App\Models\Project\Project;
  16 +
  17 +class GeoLogic extends BaseLogic
  18 +{
  19 + public function __construct()
  20 + {
  21 + parent::__construct();
  22 + $this->param = $this->requestAll;
  23 + $this->model = new GeoQuestion();
  24 + }
  25 +
  26 + /**
  27 + * @remark :设置geo状态
  28 + * @name :setGeoStatus
  29 + * @author :lyh
  30 + * @method :post
  31 + * @time :2025/7/2 17:51
  32 + */
  33 + public function setGeoStatus(){
  34 + $projectModel = new Project();
  35 + $data = $projectModel->edit(['geo_status'=>$this->param['geo_status'],'geo_frequency'=>$this->param['geo_frequency']],['id'=>$this->param['project_id']]);
  36 + $questionModel = new GeoQuestion();
  37 + $questionModel->edit(['status'=>$this->param['geo_status']],['project_id'=>$this->param['project_id']]);
  38 + return $this->success($data);
  39 + }
  40 +
  41 + /**
  42 + * @remark :获取类型
  43 + * @name :getType
  44 + * @author :lyh
  45 + * @method :post
  46 + * @time :2025/7/3 10:47
  47 + */
  48 + public function getType(){
  49 + $data['type'] = $this->model->brandType();
  50 + $data['frequency'] = $this->model->frequency;
  51 + $geoPlatformModel = new GeoPlatform();
  52 + $data['platform'] = $geoPlatformModel->getList();
  53 + return $this->success($data);
  54 + }
  55 +
  56 + /**
  57 + * @remark :获取问题列表
  58 + * @name :getGeoQuestionList
  59 + * @author :lyh
  60 + * @method :post
  61 + * @time :2025/7/3 9:12
  62 + */
  63 + public function getGeoQuestionList($map,$page,$row,$order,$field = ['*']){
  64 + $data = $this->model->lists($map,$page,$row,$order,$field);
  65 + if(!empty($data) && !empty($data['list'])){
  66 + foreach ($data['list'] as $key => $item){
  67 + $item['type_name'] = $this->model->brandType()[$item['type']];
  68 + $data['list'][$key] = $item;
  69 + }
  70 + }
  71 + return $this->success($data);
  72 + }
  73 +
  74 + /**
  75 + * @remark :保存数据
  76 + * @name :saveGeoQuestion
  77 + * @author :lyh
  78 + * @method :post
  79 + * @time :2025/7/3 9:47
  80 + * @param : question->提交的问题
  81 + * @param : url->提交的网址
  82 + * @param : keywords->提交的关键字
  83 + * @param : project_id->项目id
  84 + */
  85 + public function saveGeoQuestion(){
  86 + //处理数据
  87 + $this->param['question'] = json_encode($this->param['question'] ?? [],true);
  88 + $this->param['url'] = json_encode($this->param['url'] ?? [],true);
  89 + $this->param['keywords'] = json_encode($this->param['keywords'] ?? [],true);
  90 + //执行时间设置为今天
  91 + $this->param['next_time'] = date('Y-m-d');
  92 + if(isset($this->param['id']) && !empty($this->param['id'])){
  93 + $id = $this->param['id'];
  94 + $this->model->edit($this->param,['id'=>$id]);
  95 + }else{
  96 + $id = $this->model->addReturnId($this->param);
  97 + }
  98 + return $this->success(['id'=>$id]);
  99 + }
  100 +
  101 + /**
  102 + * @remark :删除数据
  103 + * @name :delGeoQuestion
  104 + * @author :lyh
  105 + * @method :post
  106 + * @time :2025/7/3 10:13
  107 + */
  108 + public function delGeoQuestion(){
  109 + $data = $this->model->del(['id'=>['in',$this->param['ids']]]);
  110 + return $this->success($data);
  111 + }
  112 +}
@@ -484,7 +484,7 @@ class ProjectLogic extends BaseLogic @@ -484,7 +484,7 @@ class ProjectLogic extends BaseLogic
484 } 484 }
485 $param['upload_config'] = json_encode($param['upload_config'] ?? []); 485 $param['upload_config'] = json_encode($param['upload_config'] ?? []);
486 $param['web_traffic_config'] = json_encode($param['web_traffic_config'] ?? []); 486 $param['web_traffic_config'] = json_encode($param['web_traffic_config'] ?? []);
487 - unset($param['robots'],$param['is_analysis']);//项目不保存robots 487 + unset($param['robots'],$param['is_analysis'],$param['geo_status'],$param['geo_frequency']);//项目单独保存的数据
488 $this->model->edit($param,['id'=>$param['id']]); 488 $this->model->edit($param,['id'=>$param['id']]);
489 Common::del_user_cache($this->model->getTable(),$param['id']); 489 Common::del_user_cache($this->model->getTable(),$param['id']);
490 return $this->success(); 490 return $this->success();
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :GeoQuestionResLogic.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/7/4 9:47
  8 + */
  9 +
  10 +namespace App\Http\Logic\Bside\Geo;
  11 +
  12 +use App\Http\Logic\Bside\BaseLogic;
  13 +use App\Models\Geo\GeoQuestionResult;
  14 +
  15 +class GeoQuestionResLogic extends BaseLogic
  16 +{
  17 + public function __construct()
  18 + {
  19 + parent::__construct();
  20 + $this->model = new GeoQuestionResult();
  21 + $this->param = $this->requestAll;
  22 + }
  23 +
  24 + /**
  25 + * @remark :获取列表页数据
  26 + * @name :getResultList
  27 + * @author :lyh
  28 + * @method :post
  29 + * @time :2025/7/4 9:48
  30 + */
  31 + public function getResultList($map = [],$page = 1,$row = 20,$order = 'id'){
  32 + $filed = ['id','project_id','question_id','platform','question','keywords','url'];
  33 + $data = $this->model->lists($map,$page,$row,$order,$filed);
  34 + return $this->success($data);
  35 + }
  36 +
  37 + /**
  38 + * @remark :获取数据详情
  39 + * @name :getResultInfo
  40 + * @author :lyh
  41 + * @method :post
  42 + * @time :2025/7/4 10:19
  43 + */
  44 + public function getResultInfo(){
  45 + $data = $this->model->read($this->param);
  46 + return $this->success($data);
  47 + }
  48 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :GeoPlatform.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/7/3 11:16
  8 + */
  9 +
  10 +namespace App\Models\Geo;
  11 +
  12 +use App\Models\Base;
  13 +use Illuminate\Support\Facades\Cache;
  14 +
  15 +/**
  16 + * @remark :geo设置平台类型
  17 + * @name :GeoPlatform
  18 + * @author :lyh
  19 + * @method :post
  20 + * @time :2025/7/3 11:16
  21 + */
  22 +class GeoPlatform extends Base
  23 +{
  24 + protected $table = 'gl_geo_platform';
  25 +
  26 + const STATUS_ON = 1;
  27 +
  28 + /**
  29 + * @remark :获取平台列表
  30 + * @name :getList
  31 + * @author :lyh
  32 + * @method :post
  33 + * @time :2025/7/3 11:18
  34 + */
  35 + public function getList(){
  36 +// $data = Cache::get('geo_platform');
  37 +// if(empty($data)){
  38 + $data = $this->list(['status'=>$this::STATUS_ON],'id',['name','en_name','icon','sort'],'desc');
  39 + Cache::put('geo_platform',$data,'12 * 3600');
  40 +// }
  41 + return $data;
  42 + }
  43 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :GeoQuestion.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/7/3 9:05
  8 + */
  9 +
  10 +namespace App\Models\Geo;
  11 +
  12 +use App\Helper\Arr;
  13 +use App\Models\Base;
  14 +
  15 +/**
  16 + * @remark :geo设置问题表
  17 + * @name :GeoQuestion
  18 + * @author :lyh
  19 + * @method :post
  20 + * @time :2025/7/3 9:05
  21 + */
  22 +class GeoQuestion extends Base
  23 +{
  24 + protected $table = 'gl_geo_question';
  25 +
  26 + public $frequency = [1,2,3,4,5,6,7,8,9,10];//类型
  27 +
  28 + /**
  29 + * @remark :geo提交网址获取器
  30 + * @name :getUrlAttribute
  31 + * @author :lyh
  32 + * @method :post
  33 + * @time :2025/7/3 9:52
  34 + */
  35 + public function getUrlAttribute($value)
  36 + {
  37 + if($value){
  38 + $value = Arr::s2a($value);
  39 + }
  40 + return $value;
  41 + }
  42 +
  43 + /**
  44 + * @remark :geo提交问题获取器
  45 + * @name :getUrlAttribute
  46 + * @author :lyh
  47 + * @method :post
  48 + * @time :2025/7/3 9:53
  49 + */
  50 + public function getQuestionAttribute($value)
  51 + {
  52 + if($value){
  53 + $value = Arr::s2a($value);
  54 + }
  55 + return $value;
  56 + }
  57 +
  58 + /**
  59 + * @remark :geo提交关键字获取器
  60 + * @name :getUrlAttribute
  61 + * @author :lyh
  62 + * @method :post
  63 + * @time :2025/7/3 9:53
  64 + */
  65 + public function getKeywordsAttribute($value)
  66 + {
  67 + if($value){
  68 + $value = Arr::s2a($value);
  69 + }
  70 + return $value;
  71 + }
  72 +
  73 + /**
  74 + * @remark :品牌类型
  75 + * @name :brandType
  76 + * @author :lyh
  77 + * @method :post
  78 + * @time :2025/7/3 9:43
  79 + */
  80 + public function brandType(){
  81 + return [
  82 + 1=>'品牌数据',
  83 + 2=>'营销数据'
  84 + ];
  85 + }
  86 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :GeoQuestionLog.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/7/4 9:31
  8 + */
  9 +
  10 +namespace App\Models\Geo;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +/**
  15 + * @remark :geo设置请求日志
  16 + * @name :GeoQuestionLog
  17 + * @author :lyh
  18 + * @method :post
  19 + * @time :2025/7/4 9:32
  20 + */
  21 +class GeoQuestionLog extends Base
  22 +{
  23 + protected $table = 'gl_geo_question_log';
  24 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :GeoQuestionResController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/7/3 16:01
  8 + */
  9 +
  10 +namespace App\Models\Geo;
  11 +
  12 +use App\Helper\Arr;
  13 +use App\Models\Base;
  14 +
  15 +/**
  16 + * @remark :geo设置请求结果
  17 + * @name :GeoQuestionResController
  18 + * @author :lyh
  19 + * @method :post
  20 + * @time :2025/7/3 16:01
  21 + */
  22 +class GeoQuestionResult extends Base
  23 +{
  24 + protected $table = 'gl_geo_question_result';
  25 + /**
  26 + * @remark :geo提交关键字获取器
  27 + * @name :getUrlAttribute
  28 + * @author :lyh
  29 + * @method :post
  30 + * @time :2025/7/3 9:53
  31 + */
  32 + public function getKeywordsAttribute($value)
  33 + {
  34 + if($value){
  35 + $value = Arr::s2a($value);
  36 + }
  37 + return $value;
  38 + }
  39 +
  40 + /**
  41 + * @remark :geo提交网址获取器
  42 + * @name :getUrlAttribute
  43 + * @author :lyh
  44 + * @method :post
  45 + * @time :2025/7/3 9:52
  46 + */
  47 + public function getUrlAttribute($value)
  48 + {
  49 + if($value){
  50 + $value = Arr::s2a($value);
  51 + }
  52 + return $value;
  53 + }
  54 +
  55 +}
  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 setWebSearchChatAction($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 + ],
  40 + 'platform'=>$platform,
  41 + 'security_check'=>true
  42 + ];
  43 + $data = http_post($url,json_encode($message,true),$header);
  44 + return $data;
  45 + }
  46 +}
@@ -553,7 +553,16 @@ Route::middleware(['aloginauth'])->group(function () { @@ -553,7 +553,16 @@ Route::middleware(['aloginauth'])->group(function () {
553 Route::any('/', [Aside\PackDir\PackDirController::class, 'getTaskLists'])->name('admin.pack_dir_getTaskLists'); 553 Route::any('/', [Aside\PackDir\PackDirController::class, 'getTaskLists'])->name('admin.pack_dir_getTaskLists');
554 Route::any('/saveTask', [Aside\PackDir\PackDirController::class, 'saveTask'])->name('admin.pack_dir_saveTask'); 554 Route::any('/saveTask', [Aside\PackDir\PackDirController::class, 'saveTask'])->name('admin.pack_dir_saveTask');
555 }); 555 });
556 - 556 + //geo设置
  557 + Route::prefix('geo')->group(function () {
  558 + Route::any('/setGeoStatus', [Aside\Geo\GeoQuestionController::class, 'setGeoStatus'])->name('admin.geo_setGeoStatus');//开启与关闭geo设置
  559 + Route::any('/getType', [Aside\Geo\GeoQuestionController::class, 'getType'])->name('admin.geo_getType');//geo设置类型
  560 + Route::prefix('question')->group(function () {
  561 + Route::any('/getGeoQuestionList', [Aside\Geo\GeoQuestionController::class, 'getGeoQuestionList'])->name('admin.geo_question_getGeoQuestionList');
  562 + Route::any('/saveGeoQuestion', [Aside\Geo\GeoQuestionController::class, 'saveGeoQuestion'])->name('admin.geo_question_saveGeoQuestion');
  563 + Route::any('/delGeoQuestion', [Aside\Geo\GeoQuestionController::class, 'delGeoQuestion'])->name('admin.geo_question_delGeoQuestion');
  564 + });
  565 + });
557 // 任务相关 566 // 任务相关
558 Route::prefix('task')->group(function () { 567 Route::prefix('task')->group(function () {
559 // FB广告相关路由 568 // FB广告相关路由
@@ -748,6 +748,12 @@ Route::middleware(['bloginauth'])->group(function () { @@ -748,6 +748,12 @@ Route::middleware(['bloginauth'])->group(function () {
748 Route::prefix('authority_score')->group(function () { 748 Route::prefix('authority_score')->group(function () {
749 Route::any('/authorityScoreInfo', [\App\Http\Controllers\Bside\BCom\AuthorityScoreController::class,'AuthorityScoreInfo'])->name('authority_score_AuthorityScoreInfo'); 749 Route::any('/authorityScoreInfo', [\App\Http\Controllers\Bside\BCom\AuthorityScoreController::class,'AuthorityScoreInfo'])->name('authority_score_AuthorityScoreInfo');
750 }); 750 });
  751 +
  752 + //geo设置
  753 + Route::prefix('geo_result')->group(function () {
  754 + Route::any('/getList', [\App\Http\Controllers\Bside\Geo\GeoQuestionResController::class,'getList'])->name('geo_result_getList');
  755 + Route::any('/getInfo', [\App\Http\Controllers\Bside\Geo\GeoQuestionResController::class,'getInfo'])->name('geo_result_getInfo');
  756 + });
751 }); 757 });
752 //无需登录验证的路由组 758 //无需登录验证的路由组
753 Route::group([], function () { 759 Route::group([], function () {