作者 李宇航

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

gx



查看合并请求 !1644
@@ -80,6 +80,25 @@ class GoogleKeywordInsightController extends BaseController @@ -80,6 +80,25 @@ class GoogleKeywordInsightController extends BaseController
80 } 80 }
81 81
82 /** 82 /**
  83 + * @remark :保存一条关键字数据
  84 + * @name :getKeywordInsightDetail
  85 + * @author :lyh
  86 + * @method :post
  87 + * @time :2025/4/1 11:23
  88 + */
  89 + public function getKeywordInsightDetail(GoogleKeywordInsightLogic $logic){
  90 + $this->request->validate([
  91 + 'keyword' => 'required'
  92 + ],[
  93 + 'keyword.required' => '关键词不能为空',
  94 + ]);
  95 + $result = $logic->getGoogleInsightDetail();
  96 + $detailModel = new GoogleKeywordInsightDetail();
  97 + $data = $detailModel->read(['id'=>$result['id']]);
  98 + $this->response('success',Code::SUCCESS,$data);
  99 + }
  100 +
  101 + /**
83 * @remark :查看当前数据是否存在数组中 102 * @remark :查看当前数据是否存在数组中
84 * @name :getSearchDetail 103 * @name :getSearchDetail
85 * @author :lyh 104 * @author :lyh
@@ -55,4 +55,29 @@ class GoogleKeywordInsightLogic extends BaseLogic @@ -55,4 +55,29 @@ class GoogleKeywordInsightLogic extends BaseLogic
55 } 55 }
56 return $this->success(); 56 return $this->success();
57 } 57 }
  58 +
  59 + /**
  60 + * @remark :保存一条数据
  61 + * @name :saveGoogleKeywordInsight
  62 + * @author :lyh
  63 + * @method :post
  64 + * @time :2025/3/25 14:36
  65 + */
  66 + public function getGoogleInsightDetail(){
  67 + $this->service = new GoogleSearchService();
  68 + $data = $this->service->requestUrl($this->param['keyword']);
  69 + if(!empty($data)){
  70 + DB::beginTransaction();
  71 + //保存数据库
  72 + try {
  73 + $detailModel = new GoogleKeywordInsightDetail();
  74 + $id = $detailModel->saveInsightDetailOne($this->user['project_id'],$this->param['keyword'],$data[0]);
  75 + DB::commit();
  76 + }catch (\Exception $e){
  77 + DB::rollBack();
  78 + $this->fail('保存失败,请联系管理员');
  79 + }
  80 + }
  81 + return $this->success(['id'=>$id ?? 0]);
  82 + }
58 } 83 }
@@ -43,4 +43,28 @@ class GoogleKeywordInsightDetail extends Base @@ -43,4 +43,28 @@ class GoogleKeywordInsightDetail extends Base
43 } 43 }
44 return $this->insertAll($saveData); 44 return $this->insertAll($saveData);
45 } 45 }
  46 +
  47 + /**
  48 + * @remark :保存一条数据
  49 + * @name :saveInsightDetailOne
  50 + * @author :lyh
  51 + * @method :post
  52 + * @time :2025/4/1 11:32
  53 + */
  54 + public function saveInsightDetailOne($project_id,$keyword,$data){
  55 + $transData = Translate::tran($data['text'], 'zh');
  56 + $saveData = [
  57 + 'search'=>$keyword,
  58 + 'text'=>$data['text'],
  59 + 'zh_text'=>$transData ?? $data['text'],
  60 + 'project_id'=>$project_id,
  61 + 'volume'=>$data['volume'],
  62 + 'competition_level'=>$data['competition_level'],
  63 + 'competition_index'=>$data['competition_index'],
  64 + 'low_bid'=>$data['low_bid'],
  65 + 'high_bid'=>$data['high_bid'],
  66 + 'trend'=>$data['trend'],
  67 + ];
  68 + return $this->addReturnId($saveData);
  69 + }
46 } 70 }
@@ -700,6 +700,8 @@ Route::middleware(['bloginauth'])->group(function () { @@ -700,6 +700,8 @@ Route::middleware(['bloginauth'])->group(function () {
700 Route::prefix('google_keyword_insight')->group(function () { 700 Route::prefix('google_keyword_insight')->group(function () {
701 Route::any('/getKeywordInsight', [\App\Http\Controllers\Bside\GoogleKeyword\GoogleKeywordInsightController::class, 'getKeywordInsight'])->name('google_keyword_insight_getKeywordInsight'); 701 Route::any('/getKeywordInsight', [\App\Http\Controllers\Bside\GoogleKeyword\GoogleKeywordInsightController::class, 'getKeywordInsight'])->name('google_keyword_insight_getKeywordInsight');
702 Route::any('/getOptimizeList', [\App\Http\Controllers\Bside\GoogleKeyword\GoogleKeywordInsightController::class, 'getOptimizeList'])->name('google_keyword_insight_getOptimizeList'); 702 Route::any('/getOptimizeList', [\App\Http\Controllers\Bside\GoogleKeyword\GoogleKeywordInsightController::class, 'getOptimizeList'])->name('google_keyword_insight_getOptimizeList');
  703 + Route::any('/getKeywordInsightDetail', [\App\Http\Controllers\Bside\GoogleKeyword\GoogleKeywordInsightController::class, 'getKeywordInsightDetail'])->name('google_keyword_insight_getKeywordInsightDetail');
  704 +
703 }); 705 });
704 //google搜索数据 706 //google搜索数据
705 Route::prefix('google_search')->group(function () { 707 Route::prefix('google_search')->group(function () {