添加异常

This commit is contained in:
youda 2025-04-18 14:04:18 +08:00
parent 9bd5d0b7d7
commit 9579f994f7

View File

@ -65,7 +65,9 @@ class User extends Base
$field = '*'; $field = '*';
$order = 'id desc'; $order = 'id desc';
$data = UserModel::getList($where, $field, $order, $limit); $data = UserModel::getList($where, $field, $order, $limit);
if ($data && $data['list']) {
foreach ($data['list'] as &$value) { foreach ($data['list'] as &$value) {
try {
$pid_info = UserModel::field('id,nickname,headimg,uid')->where(['id' => $value['pid']])->find(); $pid_info = UserModel::field('id,nickname,headimg,uid')->where(['id' => $value['pid']])->find();
$value['pid_info'] = $pid_info; $value['pid_info'] = $pid_info;
#关联user_account #关联user_account
@ -113,8 +115,11 @@ class User extends Base
$value['ip_adcode'] = $user_account['ip_adcode']; $value['ip_adcode'] = $user_account['ip_adcode'];
$value['ip_province'] = $user_account['ip_province']; $value['ip_province'] = $user_account['ip_province'];
$value['ip_city'] = $user_account['ip_city']; $value['ip_city'] = $user_account['ip_city'];
} catch (\Throwable $th) {
//throw $th;
}
}
} }
// 获取数据 // 获取数据
$list = $data['list']; $list = $data['list'];
@ -857,7 +862,7 @@ class User extends Base
// 将UID转换为用户ID // 将UID转换为用户ID
$user_id = $this->convertUidToUserId($user_id); $user_id = $this->convertUidToUserId($user_id);
if(empty($user_id)) { if (empty($user_id)) {
return json(['code' => 1, 'msg' => '参数错误', 'count' => 0, 'data' => []]); return json(['code' => 1, 'msg' => '参数错误', 'count' => 0, 'data' => []]);
} }
@ -966,10 +971,10 @@ class User extends Base
public function user_order() public function user_order()
{ {
$id = input('id'); $id = input('id');
View::assign('id',$id); View::assign('id', $id);
View::assign('user_id',$id); View::assign('user_id', $id);
$nickname = input('nickname'); $nickname = input('nickname');
View::assign('nickname',$nickname); View::assign('nickname', $nickname);
return View::fetch('User/user_order'); return View::fetch('User/user_order');
} }
@ -984,7 +989,7 @@ class User extends Base
// 将UID转换为用户ID // 将UID转换为用户ID
$user_id = $this->convertUidToUserId($user_id); $user_id = $this->convertUidToUserId($user_id);
if(empty($user_id)) { if (empty($user_id)) {
return json(['code' => 1, 'msg' => '参数错误', 'count' => 0, 'data' => []]); return json(['code' => 1, 'msg' => '参数错误', 'count' => 0, 'data' => []]);
} }
@ -1305,11 +1310,15 @@ class User extends Base
// 计算活跃用户数 // 计算活跃用户数
$active_user_count = \app\common\model\UserLoginLog::getActiveUserCount($start_date, $end_date); $active_user_count = \app\common\model\UserLoginLog::getActiveUserCount($start_date, $end_date);
return json(['code' => 0, 'msg' => 'ok', 'data' => [ return json([
'code' => 0,
'msg' => 'ok',
'data' => [
'chart' => $chart_data, 'chart' => $chart_data,
'active_users' => $active_user_count, 'active_users' => $active_user_count,
'total_logins' => array_sum($values), 'total_logins' => array_sum($values),
]]); ]
]);
break; break;
case 'week': case 'week':
@ -1329,10 +1338,14 @@ class User extends Base
'values' => $values, 'values' => $values,
]; ];
return json(['code' => 0, 'msg' => 'ok', 'data' => [ return json([
'code' => 0,
'msg' => 'ok',
'data' => [
'chart' => $chart_data, 'chart' => $chart_data,
'total_logins' => array_sum($values), 'total_logins' => array_sum($values),
]]); ]
]);
break; break;
case 'month': case 'month':
@ -1352,10 +1365,14 @@ class User extends Base
'values' => $values, 'values' => $values,
]; ];
return json(['code' => 0, 'msg' => 'ok', 'data' => [ return json([
'code' => 0,
'msg' => 'ok',
'data' => [
'chart' => $chart_data, 'chart' => $chart_data,
'total_logins' => array_sum($values), 'total_logins' => array_sum($values),
]]); ]
]);
break; break;
default: default: