update
This commit is contained in:
parent
087e72abef
commit
42af6df23e
|
@ -23,4 +23,9 @@ class UserController extends BaseAdminController
|
|||
$detail = UserLogic::detail($params['id']);
|
||||
return $this->success('', $detail);
|
||||
}
|
||||
|
||||
// 用户余额列表
|
||||
public function balanceLists() {
|
||||
|
||||
}
|
||||
}
|
|
@ -12,20 +12,20 @@ class UserLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['user_status'],
|
||||
'%like%' => ['user_account','user_nickname','user_phone'],
|
||||
'=' => ['status'],
|
||||
'%like%' => ['nick_name','phone'],
|
||||
];
|
||||
}
|
||||
|
||||
// 获取用户列表
|
||||
public function lists(): array
|
||||
{
|
||||
$field = "id,user_avatar,user_account,user_nickname,user_phone,user_gender,user_status,create_time";
|
||||
$lists = User::field($field)->where($this->searchWhere)->where('user_status','<>',2)
|
||||
$field = "id,phone,avatar,nick_name,real_name,id_card,gender,age,total_balance,total_integral,status,create_time";
|
||||
$lists = User::field($field)->where($this->searchWhere)->where('status','<>',2)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order('id desc')->select()->each(function($item){
|
||||
$item['user_status_text'] = $item->user_status_text;
|
||||
$item['user_gender_text'] = $item->user_gender_text;
|
||||
$item['status_text'] = $item->status_text;
|
||||
$item['gender_text'] = $item->gender_text;
|
||||
})->toArray();
|
||||
return $lists;
|
||||
}
|
||||
|
@ -33,6 +33,6 @@ class UserLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||
// 获取数量
|
||||
public function count(): int
|
||||
{
|
||||
return User::field('id')->where($this->searchWhere)->where('user_status','<>',2)->count();
|
||||
return User::field('id')->where($this->searchWhere)->where('status','<>',2)->count();
|
||||
}
|
||||
}
|
|
@ -10,10 +10,12 @@ class UserLogic extends BaseLogic
|
|||
//用户详情
|
||||
public static function detail(int $userId): array
|
||||
{
|
||||
$field = ['id','user_phone','user_avatar','user_name','user_gender','user_age','user_status','user_last_login_time','user_last_login_ip','create_time'];
|
||||
$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'];
|
||||
$user = User::field($field)->where(['id' => $userId])->findOrEmpty();
|
||||
$user['user_gender_text'] = $user->user_gender_text;
|
||||
$user['user_status_text'] = $user->user_status_text;
|
||||
$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;
|
||||
unset($user['province'],$user['city'],$user['area'],$user['street'],$user['village'],$user['brigade']);
|
||||
return $user->toArray();
|
||||
}
|
||||
}
|
|
@ -3,22 +3,76 @@
|
|||
namespace app\common\model\user;
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class User extends BaseModel
|
||||
{
|
||||
protected $name = 'user';
|
||||
|
||||
// 获取用户状态
|
||||
public function getUserStatusTextAttr($value,$data): string
|
||||
public function getStatusTextAttr($value,$data): string
|
||||
{
|
||||
$user_status = [0=>'正常',1=>'冻结',2=>'删除'];
|
||||
return $user_status[$data['user_status']];
|
||||
$status = [0=>'正常',1=>'冻结',2=>'删除'];
|
||||
return $status[$data['status']];
|
||||
}
|
||||
|
||||
// 获取用户性别
|
||||
public function getUserGenderTextAttr($value,$data): string
|
||||
public function getGenderTextAttr($value,$data): string
|
||||
{
|
||||
$user_gender = [0=>'男',1=>'女',2=>'未知'];
|
||||
return $user_gender[$data['user_gender']];
|
||||
$gender = [0=>'男',1=>'女',2=>'未知'];
|
||||
return $gender[$data['gender']];
|
||||
}
|
||||
|
||||
public function getProvinceTextAttr($value,$data): string {
|
||||
$data = Db::name('geo_province')->where('province_code',$data['province'])->findOrEmpty();
|
||||
if(empty($data)){
|
||||
return '';
|
||||
}
|
||||
return $data['province_name'];
|
||||
}
|
||||
|
||||
public function getCityTextAttr($value,$data): string {
|
||||
$data = Db::name('geo_city')->where('city_code',$data['city'])->findOrEmpty();
|
||||
if(empty($data)){
|
||||
return '';
|
||||
}
|
||||
return $data['city_name'];
|
||||
}
|
||||
|
||||
public function getAreaTextAttr($value,$data): string {
|
||||
$data = Db::name('geo_area')->where('area_code',$data['area'])->findOrEmpty();
|
||||
if(empty($data)){
|
||||
return '';
|
||||
}
|
||||
return $data['area_name'];
|
||||
}
|
||||
|
||||
public function getStreetTextAttr($value,$data): string {
|
||||
$data = Db::name('geo_street')->where('street_code',$data['street'])->findOrEmpty();
|
||||
if(empty($data)){
|
||||
return '';
|
||||
}
|
||||
return $data['street_name'];
|
||||
}
|
||||
|
||||
public function getVillageTextAttr($value,$data): string {
|
||||
$data = Db::name('geo_village')->where('village_code',$data['village'])->findOrEmpty();
|
||||
if(empty($data)){
|
||||
return '';
|
||||
}
|
||||
return $data['village_name'];
|
||||
}
|
||||
|
||||
public function getBrigadeTextAttr($value,$data): string {
|
||||
$data = Db::name('geo_brigade')->where('id',$data['brigade'])->findOrEmpty();
|
||||
if(empty($data)){
|
||||
return '';
|
||||
}
|
||||
return $data['brigade_name'];
|
||||
}
|
||||
|
||||
public function getLastLoginTimeAttr($value): string
|
||||
{
|
||||
return date('Y-m-d H:i:s',$value);
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ use app\common\validate\BaseValidate;
|
|||
class UserValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'phone' => 'require|mobile|unique:user',
|
||||
'code' => 'require',
|
||||
'age' => 'number|gt:0',
|
||||
|
@ -24,6 +25,7 @@ class UserValidate extends BaseValidate
|
|||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '请选择用户',
|
||||
'phone.require' => '请输入手机号码',
|
||||
'phone.mobile' => '请输入正确的手机号码',
|
||||
'phone.unique' => '该手机号码已注册',
|
||||
|
@ -42,6 +44,11 @@ class UserValidate extends BaseValidate
|
|||
'brigade.number' => '小组编码值错误',
|
||||
];
|
||||
|
||||
public function sceneDetail(): UserValidate
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function sceneChangeMobile(): UserValidate
|
||||
{
|
||||
return $this->only(['phone','code']);
|
||||
|
|
Loading…
Reference in New Issue