From 43413c5778979dcad29f03ba3b101db8eb38235c Mon Sep 17 00:00:00 2001 From: monanxiao Date: Sat, 18 Mar 2023 10:50:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=90=8E=E5=8F=B0=E4=BE=9B?= =?UTF-8?q?=E5=BA=94=E9=93=BE=E7=9B=B8=E5=85=B3=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/SupplyTeam.php | 33 +++++++++++++++++++----- app/admin/model/GeoVillage.php | 19 ++++++++++++++ app/admin/model/SupplyTeam.php | 12 +++++++++ app/admin/view/supply_team/datalist.html | 16 +++++++++++- app/common/model/User.php | 2 ++ 5 files changed, 75 insertions(+), 7 deletions(-) create mode 100644 app/admin/model/GeoVillage.php diff --git a/app/admin/controller/SupplyTeam.php b/app/admin/controller/SupplyTeam.php index 1524bd7..ff3ed69 100644 --- a/app/admin/controller/SupplyTeam.php +++ b/app/admin/controller/SupplyTeam.php @@ -16,6 +16,10 @@ use think\exception\ValidateException; use think\facade\Db; use think\facade\View; use app\admin\model\Admin; +use app\admin\model\GeoCity; +use app\admin\model\GeoArea; +use app\admin\model\GeoStreet; +use app\admin\model\GeoVillage; class SupplyTeam extends BaseController @@ -37,14 +41,31 @@ class SupplyTeam extends BaseController $param = get_params(); $where = []; - $list = $this->model->with('level')->select(); + $list = $this->model->with(['level', 'user'])->select(); $total = $this->model->count(); // $list = $this->model->getSupplyTeamList($where,$param); - // foreach ($list as $k =>$v){ - // $list[$k]['area_id'] = Db::table('fa_geo_area')->where('area_id',$v['parent_code'])->value('area_name'); - // $list[$k]['supply_level_id'] = Db::table('fa_supply_level')->where('id',$v['supply_level_id'])->value('name'); - // $list[$k]['user_id'] = Db::table('fa_szxc_information_usermsg')->where('user_id',$v['user_id'])->value('name'); - // } + foreach ($list as $k =>$v){ + + switch ($v['auth_range']) { + case 1: + $list[$k]['address'] = GeoVillage::where('village_code', $v['parent_code'])->value('village_name'); + $list[$k]['auth_range'] = '村'; + break; + case 2: + $list[$k]['address'] = GeoStreet::where('street_code', $v['parent_code'])->value('street_name'); + $list[$k]['auth_range'] = '乡镇'; + break; + case 3: + $list[$k]['address'] = GeoArea::where('area_code', $v['parent_code'])->value('area_name'); + $list[$k]['auth_range'] = '区县'; + break; + case 4: + $list[$k]['address'] = GeoCity::where('city_code', $v['parent_code'])->value('city_name'); + $list[$k]['auth_range'] = '市'; + break; + } + } + $result = ['total' => $total, 'data' => $list]; return table_assign(0, '', $result); diff --git a/app/admin/model/GeoVillage.php b/app/admin/model/GeoVillage.php new file mode 100644 index 0000000..d308a6d --- /dev/null +++ b/app/admin/model/GeoVillage.php @@ -0,0 +1,19 @@ +hasOne(SupplyLevel::class, 'id', 'supply_level_id'); } + /** + * + * 管理后台用户 + * + */ + public function user() + { + return $this->hasOne(User::class, 'id', 'user_id'); + } + /** * 获取分页列表 * @param $where diff --git a/app/admin/view/supply_team/datalist.html b/app/admin/view/supply_team/datalist.html index 35c3009..3d90417 100644 --- a/app/admin/view/supply_team/datalist.html +++ b/app/admin/view/supply_team/datalist.html @@ -62,15 +62,29 @@ return d.level.name + ',分佣比例:' + d.level.rate + '%'; } },{ - field: 'user_id', + field: 'user', title: '后台负责人', align: 'center', + // width: 100, + templet: function (d) + { + return d.user.nickname + ',手机号:' + d.user.mobile; + } + },{ + field: 'auth_range', + title: '权限', + align: 'center', width: 100 },{ field: 'parent_code', title: '市/区县/镇/村', align: 'center', width: 100 + },{ + field: 'address', + title: '市/区县/镇/村', + align: 'center', + width: 100 },{ field: 'brokerage', title: '分佣金额', diff --git a/app/common/model/User.php b/app/common/model/User.php index fb32b75..16424a3 100644 --- a/app/common/model/User.php +++ b/app/common/model/User.php @@ -17,6 +17,8 @@ class User extends BaseModel 'url', ]; + protected $table = "fa_user"; + /** * 获取个人URL. *