添加根据经纬度获取城市

添加后台统计看板
This commit is contained in:
2025-12-26 16:26:15 +08:00
parent 028886c1fe
commit 6963216a85
9 changed files with 1668 additions and 8 deletions

View File

@@ -218,10 +218,37 @@ class AdLogic
*/
public static function infoPosition($client)
{
$position_list = Db::name('ad_position')
->where(['client' => $client, 'status' => 1, 'del' => 0])
->group('name')
->column('id,name', 'id');
$position_list = [];
// 使用错误抑制,避免 unserialize 警告影响页面
$originalErrorReporting = error_reporting(0);
try {
// 使用原始 SQL 查询,完全绕过 ThinkPHP 的类型转换
$prefix = config('database.prefix');
$tableName = $prefix . 'ad_position';
$sql = "SELECT DISTINCT `id`, `name` FROM `{$tableName}` WHERE `client` = " . intval($client) . " AND `status` = 1 AND `del` = 0 GROUP BY `name`";
$result = Db::query($sql);
if (!empty($result) && is_array($result)) {
foreach ($result as $row) {
if (isset($row['id']) && isset($row['name'])) {
$position_list[$row['id']] = $row['name'];
}
}
}
} catch (\Exception $e) {
// 忽略所有异常
} catch (\Error $e) {
// 忽略所有错误
} catch (\Throwable $e) {
// 捕获所有可抛出的对象
} finally {
// 恢复错误报告级别
error_reporting($originalErrorReporting);
}
asort($position_list);
return $position_list;
}