优化供应链小组增加

This commit is contained in:
monanxiao 2023-03-18 17:10:35 +08:00
parent 56d80852ff
commit d3e2d1bce6
8 changed files with 92 additions and 22 deletions

View File

@ -20,6 +20,7 @@ use app\admin\model\GeoCity;
use app\admin\model\GeoArea; use app\admin\model\GeoArea;
use app\admin\model\GeoStreet; use app\admin\model\GeoStreet;
use app\admin\model\GeoVillage; use app\admin\model\GeoVillage;
use app\admin\model\ShopUser;
class SupplyTeam extends BaseController class SupplyTeam extends BaseController
@ -41,7 +42,7 @@ class SupplyTeam extends BaseController
$param = get_params(); $param = get_params();
$where = []; $where = [];
$list = $this->model->with(['level', 'user'])->select(); $list = $this->model->with(['level', 'user', 'userMsg'])->select();
$total = $this->model->count(); $total = $this->model->count();
// $list = $this->model->getSupplyTeamList($where,$param); // $list = $this->model->getSupplyTeamList($where,$param);
foreach ($list as $k =>$v){ foreach ($list as $k =>$v){
@ -91,7 +92,8 @@ class SupplyTeam extends BaseController
return to_assign(1, $e->getError()); 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 = ''; $parent_code = '';
// 验证用户级别,获取对应的区域代码 // 验证用户级别,获取对应的区域代码
@ -126,15 +128,9 @@ class SupplyTeam extends BaseController
View::assign('level', $level); View::assign('level', $level);
//获取用户信息 //获取用户信息
$this->users = Db::table('fa_szxc_information_useraddress') $usersList = ShopUser::with(['userAddress', 'userMsg'])->select();
->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); View::assign('users', $usersList);
return view(); return view();
} }
} }

View File

@ -0,0 +1,22 @@
<?php
/**
* @copyright Copyright (c) 2021 勾股工作室
* @license https://opensource.org/licenses/Apache-2.0
* @link https://www.gougucms.com
*/
namespace app\admin\model;
use think\facade\Db;
use think\model;
/**
*
* 用户关联居住信息表
*
*/
class InformationUserAddress extends Model
{
// 设置当前模型对应的完整数据表名称
protected $table = 'fa_szxc_information_useraddress';
}

View File

@ -0,0 +1,22 @@
<?php
/**
* @copyright Copyright (c) 2021 勾股工作室
* @license https://opensource.org/licenses/Apache-2.0
* @link https://www.gougucms.com
*/
namespace app\admin\model;
use think\facade\Db;
use think\model;
/**
*
* 用户关联居住信息表
*
*/
class InformationUserMsg extends Model
{
// 设置当前模型对应的完整数据表名称
protected $table = 'fa_szxc_information_usermsg';
}

View File

@ -22,4 +22,23 @@ class ShopUser extends Model
protected $table = 'eb_user'; protected $table = 'eb_user';
protected $pk = 'uid'; protected $pk = 'uid';
/**
*
* 用户地址信息
*
*/
public function userAddress()
{
return $this->hasOne(InformationUserAddress::class, 'user_id', 'uid');
}
/**
*
* 用户家庭信息
*
*/
public function userMsg()
{
return $this->hasOne(InformationUserMsg::class, 'user_id', 'uid');
}
} }

View File

@ -7,6 +7,7 @@
namespace app\admin\model; namespace app\admin\model;
use think\model; use think\model;
use app\common\model\User; use app\common\model\User;
use app\admin\model\ShopUser;
class SupplyTeam extends Model class SupplyTeam extends Model
{ {
@ -30,7 +31,17 @@ class SupplyTeam extends Model
*/ */
public function user() 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');
} }
/** /**
@ -59,6 +70,7 @@ class SupplyTeam extends Model
try { try {
$param['create_time'] = time(); $param['create_time'] = time();
$insertId = self::strict(false)->field(true)->insertGetId($param); $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); add_log('add', $insertId, $param);
} catch(\Exception $e) { } catch(\Exception $e) {
return to_assign(1, '操作失败,原因:'.$e->getMessage()); return to_assign(1, '操作失败,原因:'.$e->getMessage());

View File

@ -37,7 +37,7 @@
<select name="user_id" lay-verify="required" lay-reqText="供应链后台团队负责人"> <select name="user_id" lay-verify="required" lay-reqText="供应链后台团队负责人">
<option value="">请选择</option> <option value="">请选择</option>
{volist name='users' id='vo'} {volist name='users' id='vo'}
<option value="{$vo.id}" >{$vo.username}|{$vo.nickname}</option> <option value="{$vo.uid}" >{$vo.nickname}---{$vo.userMsg.name}---{$vo.userMsg.phone}</option>
{/volist} {/volist}
</select> </select>
</td> </td>

View File

@ -68,7 +68,7 @@
// width: 100, // width: 100,
templet: function (d) templet: function (d)
{ {
return d.user.nickname + ',手机号:' + d.user.mobile; return d.userMsg.name + ',手机号:' + d.user.phone;
} }
},{ },{
field: 'auth_range', field: 'auth_range',

View File

@ -278,7 +278,6 @@ class Userinfo extends BaseController
$userinfo_data['userinfo']['address_name'] = ''; $userinfo_data['userinfo']['address_name'] = '';
} }
\think\facade\Log::info($userinfo_data);
Db::commit(); Db::commit();
$this->apiSuccess('已完善,登录成功', $userinfo_data); $this->apiSuccess('已完善,登录成功', $userinfo_data);