作者 李宇航

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

gx翻译



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