diff --git a/app/admin/controller/SupplyTeam.php b/app/admin/controller/SupplyTeam.php index ff3ed69..a188684 100644 --- a/app/admin/controller/SupplyTeam.php +++ b/app/admin/controller/SupplyTeam.php @@ -20,6 +20,7 @@ use app\admin\model\GeoCity; use app\admin\model\GeoArea; use app\admin\model\GeoStreet; use app\admin\model\GeoVillage; +use app\admin\model\ShopUser; class SupplyTeam extends BaseController @@ -41,7 +42,7 @@ class SupplyTeam extends BaseController $param = get_params(); $where = []; - $list = $this->model->with(['level', 'user'])->select(); + $list = $this->model->with(['level', 'user', 'userMsg'])->select(); $total = $this->model->count(); // $list = $this->model->getSupplyTeamList($where,$param); foreach ($list as $k =>$v){ @@ -91,7 +92,8 @@ class SupplyTeam extends BaseController return to_assign(1, $e->getError()); } - $userAdmin = Db::table('fa_szxc_information_useraddress')->where('admin_id', $param['user_id'])->find(); + $userAdmin = Db::table('fa_szxc_information_useraddress')->where('user_id', $param['user_id'])->find(); + $parent_code = ''; // 验证用户级别,获取对应的区域代码 @@ -118,7 +120,7 @@ class SupplyTeam extends BaseController $param['parent_code'] = $parent_code; // 所属区域代码 $this->model->addSupplyTeam($param); - + }else{ $geo_area = Db::table('fa_geo_area')->where('city_code',510500)->select(); View::assign('geo_area', $geo_area); @@ -126,15 +128,9 @@ class SupplyTeam extends BaseController View::assign('level', $level); //获取用户信息 - $this->users = Db::table('fa_szxc_information_useraddress') - ->alias('a') - ->where('a.status',1) - ->whereNotIn('a.id', [1]) - ->leftJoin ('nk_lihaink_cn.cms_admin b', 'a.admin_id = b.id') - ->field('b.id, b.username, b.nickname, a.admin_id, a.street_id, a.area_id, a.village_id, a.village_code, a.brigade_id') - ->select(); - - View::assign('users', $this->users); + $usersList = ShopUser::with(['userAddress', 'userMsg'])->select(); + + View::assign('users', $usersList); return view(); } } diff --git a/app/admin/model/InformationUserAddress.php b/app/admin/model/InformationUserAddress.php new file mode 100644 index 0000000..3f9f26d --- /dev/null +++ b/app/admin/model/InformationUserAddress.php @@ -0,0 +1,22 @@ +hasOne(InformationUserAddress::class, 'user_id', 'uid'); + } + + /** + * + * 用户家庭信息 + * + */ + public function userMsg() + { + return $this->hasOne(InformationUserMsg::class, 'user_id', 'uid'); + } } \ No newline at end of file diff --git a/app/admin/model/SupplyTeam.php b/app/admin/model/SupplyTeam.php index f751b62..5cdea58 100644 --- a/app/admin/model/SupplyTeam.php +++ b/app/admin/model/SupplyTeam.php @@ -7,6 +7,7 @@ namespace app\admin\model; use think\model; use app\common\model\User; +use app\admin\model\ShopUser; class SupplyTeam extends Model { @@ -30,7 +31,17 @@ class SupplyTeam extends Model */ public function user() { - return $this->hasOne(User::class, 'id', 'user_id'); + return $this->hasOne(ShopUser::class, 'uid', 'user_id'); + } + + /** + * + * 用户家庭信息 + * + */ + public function userMsg() + { + return $this->hasOne(InformationUserMsg::class, 'user_id', 'user_id'); } /** @@ -55,15 +66,16 @@ class SupplyTeam extends Model */ public function addSupplyTeam($param) { - $insertId = 0; + $insertId = 0; try { - $param['create_time'] = time(); - $insertId = self::strict(false)->field(true)->insertGetId($param); - add_log('add', $insertId, $param); + $param['create_time'] = time(); + $insertId = self::strict(false)->field(true)->insertGetId($param); + ShopUser::where('uid', $param['user_id'])->update([ 'fa_supply_team_id' => $insertId]); + add_log('add', $insertId, $param); } catch(\Exception $e) { - return to_assign(1, '操作失败,原因:'.$e->getMessage()); + return to_assign(1, '操作失败,原因:'.$e->getMessage()); } - return to_assign(0,'操作成功',['aid'=>$insertId]); + return to_assign(0,'操作成功',['aid'=>$insertId]); } /** diff --git a/app/admin/view/supply_team/add.html b/app/admin/view/supply_team/add.html index 0cc0bbf..528ca00 100644 --- a/app/admin/view/supply_team/add.html +++ b/app/admin/view/supply_team/add.html @@ -37,7 +37,7 @@ diff --git a/app/admin/view/supply_team/datalist.html b/app/admin/view/supply_team/datalist.html index 3d90417..653f95a 100644 --- a/app/admin/view/supply_team/datalist.html +++ b/app/admin/view/supply_team/datalist.html @@ -68,7 +68,7 @@ // width: 100, templet: function (d) { - return d.user.nickname + ',手机号:' + d.user.mobile; + return d.userMsg.name + ',手机号:' + d.user.phone; } },{ field: 'auth_range', diff --git a/app/api/controller/Userinfo.php b/app/api/controller/Userinfo.php index e080424..457fcde 100644 --- a/app/api/controller/Userinfo.php +++ b/app/api/controller/Userinfo.php @@ -278,7 +278,6 @@ class Userinfo extends BaseController $userinfo_data['userinfo']['address_name'] = ''; } - \think\facade\Log::info($userinfo_data); Db::commit(); $this->apiSuccess('已完善,登录成功', $userinfo_data);