作者 李宇航

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

gx翻译



查看合并请求 !1568
... ... @@ -12,6 +12,7 @@ namespace App\Http\Controllers\Bside;
use App\Enums\Common\Code;
use App\Helper\FormGlobalsoApi;
use App\Helper\PayStripeApi;
use App\Helper\Translate;
use App\Http\Logic\Bside\News\NewsLogic;
use App\Models\Ai\AiBlog;
use App\Models\Channel\Channel;
... ... @@ -42,11 +43,7 @@ class TestController extends BaseController
*/
public function ceshi(){
//获取上一周询盘数量
$service = new GoogleKeywordInsightService();
$list = $service->requestUrl('cnc');
if(!empty($list)){
}
$this->response('success',Code::SUCCESS,$list);
$transData = Translate::tran(['heidenhain programming','heidenhain tnc 620'], 'zh');
$this->response('success',Code::SUCCESS,$transData);
}
}
... ...
... ... @@ -14,6 +14,7 @@ use App\Http\Logic\Bside\BaseLogic;
use App\Models\GoogleKeywordInsight\GoogleKeywordInsight;
use App\Models\GoogleKeywordInsight\GoogleKeywordInsightDetail;
use App\Services\GoogleKeywordInsightService;
use Illuminate\Support\Facades\DB;
class GoogleKeywordInsightLogic extends BaseLogic
{
... ... @@ -39,10 +40,17 @@ class GoogleKeywordInsightLogic extends BaseLogic
$this->service = new GoogleKeywordInsightService();
$data = $this->service->requestUrl($this->param['keyword']);
if(!empty($data)){
DB::beginTransaction();
//保存数据库
$detailModel = new GoogleKeywordInsightDetail();
$this->model->saveInsight($this->user['project_id'],$this->param['keyword'],$data);
$detailModel->saveInsightDetail($this->user['project_id'],$this->param['keyword'],$data);
try {
$detailModel = new GoogleKeywordInsightDetail();
$this->model->saveInsight($this->user['project_id'],$this->param['keyword'],$data);
$detailModel->saveInsightDetail($this->user['project_id'],$this->param['keyword'],$data);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('保存失败,请联系管理员');
}
}
}
return $this->success($data);
... ...
... ... @@ -25,6 +25,7 @@ class GoogleKeywordInsightDetail extends Base
*/
public function saveInsightDetail($project_id,$keyword,$data){
$saveData = [];
$transData = $this->translateZh($data);
foreach ($data as $val){
$saveData[] = [
'search'=>$keyword,
... ... @@ -40,4 +41,15 @@ class GoogleKeywordInsightDetail extends Base
}
return $this->insertAll($saveData);
}
/**
* @remark :翻译中文
* @name :translateZh
* @author :lyh
* @method :post
* @time :2025/3/25 17:21
*/
public function translateZh($data){
return Translate::tran($data, 'zh');
}
}
... ...