From 38f124cfceb246ab45263eb77060188cd1a0fcd7 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 31 Jul 2023 17:01:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A1=A3=E6=A1=88=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/adminapi/lists/user/UserLists.php | 3 +- app/adminapi/logic/user/UserLogic.php | 13 ++-- app/api/controller/InformationController.php | 9 +++ .../model/information/UserInformationg.php | 65 ++++++++++++++----- 4 files changed, 67 insertions(+), 23 deletions(-) diff --git a/app/adminapi/lists/user/UserLists.php b/app/adminapi/lists/user/UserLists.php index 7f9fa34ce..bd1299e7c 100755 --- a/app/adminapi/lists/user/UserLists.php +++ b/app/adminapi/lists/user/UserLists.php @@ -61,8 +61,9 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface $where[]=['company_id','=',$company_id]; } } - $field = "id,sn,nickname,sex,avatar,account,mobile,channel,create_time"; + $field = "id,sn,nickname,sex,avatar,account,mobile,channel,create_time,admin_id,company_id,street,street as street_name,is_contract"; $lists = User::withSearch($this->setSearch(), $this->params) + ->with(['company']) ->where($where) ->limit($this->limitOffset, $this->limitLength) ->field($field) diff --git a/app/adminapi/logic/user/UserLogic.php b/app/adminapi/logic/user/UserLogic.php index 78b04ae0c..543fdac10 100755 --- a/app/adminapi/logic/user/UserLogic.php +++ b/app/adminapi/logic/user/UserLogic.php @@ -37,17 +37,18 @@ class UserLogic extends BaseLogic */ public static function detail(int $userId): array { - $field = [ - 'id', 'sn', 'account', 'nickname', 'avatar', 'real_name', - 'sex', 'mobile', 'create_time', 'login_time', 'channel', - 'user_money', - ]; + // $field = [ + // 'id', 'sn', 'account', 'nickname', 'avatar', 'real_name', + // 'sex', 'mobile', 'create_time', 'login_time', 'channel', + // 'user_money', + // ]; - $user = User::where(['id' => $userId])->field($field) + $user = User::where(['id' => $userId]) ->findOrEmpty(); $user['channel'] = UserTerminalEnum::getTermInalDesc($user['channel']); $user->sex = $user->getData('sex'); + $user['qualification']=json_decode($user->qualification,true); return $user->toArray(); } diff --git a/app/api/controller/InformationController.php b/app/api/controller/InformationController.php index 232667d3a..233c198ee 100644 --- a/app/api/controller/InformationController.php +++ b/app/api/controller/InformationController.php @@ -29,4 +29,13 @@ class InformationController extends BaseApiController } return $this->success('成功'); } + + public function details(){ + $param = Request()->param(); + $res = UserInformationg::details($param['id']); + if ($res != true) { + return $this->fail( BaseLogic::getError()); + } + return $this->success('成功',$res->toArray()); + } } diff --git a/app/common/model/information/UserInformationg.php b/app/common/model/information/UserInformationg.php index d22605d8f..2190d3729 100644 --- a/app/common/model/information/UserInformationg.php +++ b/app/common/model/information/UserInformationg.php @@ -6,28 +6,16 @@ use app\common\model\BaseModel; use think\facade\Db; use think\facade\Log; use app\common\logic\BaseLogic; +use app\common\model\Company; class UserInformationg extends BaseModel { public static function list($param,$page=1,$size=10){ - return self::where($param)->page($page)->limit($size)->select()->each(function($item, $key){ - $item['family'] = json_decode($item['family'],true); - $item['child_arr'] = json_decode($item['child_arr'],true); - $data=UserInformationgDemand::where('create_user_id',$item['create_user_id'])->select(); - $item['datas']=[]; - if($data){ - foreach($data as $k=>$v){ - $datas=[]; - $a=json_decode($v['data'],true); - if($a){ - array_push($datas,$a); - } - $item['datas']=$datas; - } - } - }); + return self::where($param)->with('company') + ->field('id,area_id,area_id as area_name,street_id,street_id as street_name,village_id,village_id as village_name, street_id as street_name,brigade_id,brigade_id as brigade_name,name,phone,age,address,create_time,update_time') + ->page($page)->limit($size)->select(); } public static function add($param) @@ -84,4 +72,49 @@ class UserInformationg extends BaseModel ]; UserInformationgDemand::create($data); } + + public static function details($id){ + $item=self::where('id',$id)->find(); + $item['family'] = json_decode($item['family'],true); + $item['child_arr'] = json_decode($item['child_arr'],true); + $data=UserInformationgDemand::where('create_user_id',$item['create_user_id'])->select(); + $item['datas']=[]; + if($data){ + foreach($data as $k=>$v){ + $datas=[]; + $a=json_decode($v['data'],true); + $arr=[ + 'category_id'=>$v['category_id'], + 'category_child'=>$v['category_child'], + 'datas'=>$a + ]; + if($a){ + array_push($datas,$arr); + } + $item['datas']=$datas; + } + } + return $item; + + } + + public function company() + { + return $this->hasOne(Company::class, 'id', 'company_id')->field(['id','company_name','admin_id']); + } + + public function getCityNameAttr($value) + { + return Db::name('geo_city')->where(['city_code' => $this->city])->value('city_name'); + } + + public function getAreaNameAttr($value) + { + return Db::name('geo_area')->where(['area_code' => $this->area])->value('area_name'); + } + + public function getStreetNameAttr($value) + { + return Db::name('geo_street')->where(['street_code' => $this->street])->value('street_name'); + } }