作者 lyh

gx

@@ -14,6 +14,7 @@ use App\Helper\Country; @@ -14,6 +14,7 @@ use App\Helper\Country;
14 use App\Helper\Translate; 14 use App\Helper\Translate;
15 use App\Http\Controllers\Bside\BaseController; 15 use App\Http\Controllers\Bside\BaseController;
16 use App\Models\Com\NoticeLog; 16 use App\Models\Com\NoticeLog;
  17 +use App\Models\GoogleSearch\GoogleCodeCountry;
17 use App\Models\GoogleSearch\GoogleSearch; 18 use App\Models\GoogleSearch\GoogleSearch;
18 use App\Models\GoogleSearch\GoogleSearchDetail; 19 use App\Models\GoogleSearch\GoogleSearchDetail;
19 use App\Services\RapIdApIService; 20 use App\Services\RapIdApIService;
@@ -39,8 +40,9 @@ class GoogleSearchController extends BaseController @@ -39,8 +40,9 @@ class GoogleSearchController extends BaseController
39 $data = $searchDetailModel->lists($this->map,$this->page,$this->row,'impressions'); 40 $data = $searchDetailModel->lists($this->map,$this->page,$this->row,'impressions');
40 if(!empty($data)){ 41 if(!empty($data)){
41 if($this->param['type'] == 'country'){ 42 if($this->param['type'] == 'country'){
  43 + $codeCountryModel = new GoogleCodeCountry();
42 foreach ($data['list'] as $key => $val){ 44 foreach ($data['list'] as $key => $val){
43 - $val['zh_country'] = ''; 45 + $val['zh_country'] = $codeCountryModel->getCodeCountry($val['keys']);
44 $val['click_rate'] = number_format($val['click_rate'] * 100, 2); // 保留 2 位小数 46 $val['click_rate'] = number_format($val['click_rate'] * 100, 2); // 保留 2 位小数
45 $val['impressions_rate'] = number_format($val['impressions_rate'] * 100, 2); 47 $val['impressions_rate'] = number_format($val['impressions_rate'] * 100, 2);
46 $data['list'][$key] = $val; 48 $data['list'][$key] = $val;
@@ -14,4 +14,19 @@ use App\Models\Base; @@ -14,4 +14,19 @@ use App\Models\Base;
14 class GoogleCodeCountry extends Base 14 class GoogleCodeCountry extends Base
15 { 15 {
16 protected $table = 'gl_google_code_country'; 16 protected $table = 'gl_google_code_country';
  17 +
  18 + /**
  19 + * @remark :获取国家中文
  20 + * @name :getCodeCountry
  21 + * @author :lyh
  22 + * @method :post
  23 + * @time :2025/4/3 10:26
  24 + */
  25 + public function getCodeCountry($code){
  26 + $info = $this->read(['code'=>$code],['zh_country']);
  27 + if($info !== false){
  28 + return $info['zh_country'];
  29 + }
  30 + return '未知国家';
  31 + }
17 } 32 }