2023-09-18 09:11:13 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace app\adminapi\logic\user;
|
|
|
|
|
|
|
|
use app\common\logic\BaseLogic;
|
2023-09-19 16:47:40 +08:00
|
|
|
use app\common\model\systems\System;
|
2023-09-18 09:11:13 +08:00
|
|
|
use app\common\model\user\User;
|
2023-09-19 16:47:40 +08:00
|
|
|
use app\common\model\user\UserBalance;
|
|
|
|
use app\common\model\user\UserIntegral;
|
2023-09-18 09:11:13 +08:00
|
|
|
|
|
|
|
class UserLogic extends BaseLogic
|
|
|
|
{
|
|
|
|
//用户详情
|
|
|
|
public static function detail(int $userId): array
|
|
|
|
{
|
2023-09-19 16:47:40 +08:00
|
|
|
//获取用户信息
|
2023-09-19 15:39:19 +08:00
|
|
|
$field = ['id','phone','avatar','nick_name','real_name','id_card','gender','age','total_balance','total_integral','province','city','area','street','village','brigade','address','status','last_login_time','last_login_ip','create_time'];
|
2023-09-18 09:11:13 +08:00
|
|
|
$user = User::field($field)->where(['id' => $userId])->findOrEmpty();
|
2023-09-19 15:39:19 +08:00
|
|
|
$user['address'] = $user->province_text.$user->city_text.$user->area_text.$user->street_text.$user->village_text.$user->brigade_text.$user->address;
|
|
|
|
$user['gender_text'] = $user->gender_text;
|
|
|
|
$user['status_text'] = $user->status_text;
|
2023-09-19 16:47:40 +08:00
|
|
|
//获取用户余额列表
|
|
|
|
$user['balance_list'] = UserBalance::field('id,record_id,amount,total_amount,type,pay_type,mark,appid,create_time')->where('user_id',$userId)->limit(10)->order('create_time desc')->select()->each(function($item){
|
|
|
|
$item['app'] = System::where('app_id',$item['appid'])->value('name');
|
|
|
|
$item['type_text'] = $item->type_text;
|
|
|
|
$item['pay_type_text'] = $item->pay_type_text;
|
|
|
|
unset($item['appid']);
|
|
|
|
})->toArray();
|
|
|
|
//获取用户积分列表
|
|
|
|
$user['integral_list'] = UserIntegral::field('id,record_id,amount,total_amount,type,mark,appid,create_time')->where('user_id',$userId)->limit(10)->order('create_time desc')->select()->each(function($item){
|
|
|
|
$item['app'] = System::where('app_id',$item['appid'])->value('name');
|
|
|
|
$item['type_text'] = $item->type_text;
|
|
|
|
})->toArray();
|
2023-09-19 15:39:19 +08:00
|
|
|
unset($user['province'],$user['city'],$user['area'],$user['street'],$user['village'],$user['brigade']);
|
2023-09-18 09:11:13 +08:00
|
|
|
return $user->toArray();
|
|
|
|
}
|
2023-09-19 16:47:40 +08:00
|
|
|
|
|
|
|
//用户余额列表
|
|
|
|
public static function balanceList($params): array
|
|
|
|
{
|
|
|
|
//获取用户余额列表
|
|
|
|
$fields = 'id,record_id,amount,total_amount,type,pay_type,mark,appid,create_time';
|
|
|
|
$lists = UserBalance::field($fields)->where('user_id',$params['uid'])->page($params['page_no'],$params['page_size'])->order('create_time desc')->select()->each(function($item){
|
|
|
|
$item['app'] = System::where('app_id',$item['appid'])->value('name');
|
|
|
|
$item['type_text'] = $item->type_text;
|
|
|
|
$item['pay_type_text'] = $item->pay_type_text;
|
|
|
|
unset($item['appid']);
|
|
|
|
})->toArray();
|
|
|
|
$count = UserBalance::field('id')->where('user_id',$params['uid'])->count();
|
|
|
|
return [
|
|
|
|
'count' => $count,
|
|
|
|
'page_no' => $params['page_no'],
|
|
|
|
'page_size' => $params['page_size'],
|
|
|
|
'lists' => $lists
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
//用户积分列表
|
|
|
|
public static function integralList($params): array
|
|
|
|
{
|
|
|
|
//获取用户积分列表
|
|
|
|
$fields = 'id,record_id,amount,total_amount,type,mark,appid,create_time';
|
|
|
|
$lists = UserIntegral::field($fields)->where('user_id',$params['uid'])->page($params['page_no'],$params['page_size'])->order('create_time desc')->select()->each(function($item){
|
|
|
|
$item['app'] = System::where('app_id',$item['appid'])->value('name');
|
|
|
|
$item['type_text'] = $item->type_text;
|
|
|
|
})->toArray();
|
|
|
|
$count = UserIntegral::field('id')->where('user_id',$params['uid'])->count();
|
|
|
|
return [
|
|
|
|
'count' => $count,
|
|
|
|
'page_no' => $params['page_no'],
|
|
|
|
'page_size' => $params['page_size'],
|
|
|
|
'lists' => $lists
|
|
|
|
];
|
|
|
|
}
|
2023-09-18 09:11:13 +08:00
|
|
|
}
|