作者 lyh

gx

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