|
@@ -1,4 +1,5 @@
|
|
|
<?php
|
|
|
+
|
|
|
namespace app\agent\controller;
|
|
|
|
|
|
use app\common\model\ComjobsCate;
|
|
@@ -20,336 +21,338 @@ use PHPExcel;
|
|
|
|
|
|
class User extends BaseController
|
|
|
{
|
|
|
-
|
|
|
- // 用户跟进记录
|
|
|
- public function follow()
|
|
|
- {
|
|
|
- $userid = input('userid/d');
|
|
|
- $user = UserModel::findOrEmpty($userid);
|
|
|
- $followlist = UserFollowModel::where('userid',$userid)->order('id','desc')->limit(100)->select();
|
|
|
- return view('user/follow',[
|
|
|
- 'user' => $user,
|
|
|
- 'followlist' => $followlist
|
|
|
- ]);
|
|
|
- }
|
|
|
-
|
|
|
- public function editFollow()
|
|
|
- {
|
|
|
- $userid = input('userid/d', 0);
|
|
|
- $user = UserModel::findOrEmpty($userid);
|
|
|
- if ($user->isEmpty()){
|
|
|
- exit(json_encode(array(
|
|
|
- 'code' => 1,
|
|
|
- 'msg' => "用户信息不存在。"
|
|
|
- )));
|
|
|
- }
|
|
|
- $agent = $this->access_agent;
|
|
|
- $broker = BrokerModel::where('agentid','=',$agent['id'])->findOrEmpty($user->brokerid);
|
|
|
- if ($broker->isEmpty()){
|
|
|
- exit(json_encode(array(
|
|
|
- 'code' => 1,
|
|
|
- 'msg' => "你无权限上报该用户跟进记录。"
|
|
|
- )));
|
|
|
- }
|
|
|
- UserFollowModel::create([
|
|
|
- 'userid' => $userid,
|
|
|
- 'ftype' => input('ftype/s', ""),
|
|
|
- 'remark' => input('remark/s', ""),
|
|
|
- 'createtime' => time()
|
|
|
- ]);
|
|
|
- $followstatus = input('followstatus/d', 1);
|
|
|
- $user->save([
|
|
|
- 'followstatus' => $followstatus
|
|
|
- ]);
|
|
|
- exit(json_encode(array(
|
|
|
- 'code' => 0
|
|
|
- )));
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- // 用户授权
|
|
|
- public function authsList()
|
|
|
- {
|
|
|
- $userid = input('userid/d');
|
|
|
- return view('user/authslist',[
|
|
|
- 'userid' => $userid
|
|
|
- ]);
|
|
|
- }
|
|
|
-
|
|
|
- public function listAuths()
|
|
|
- {
|
|
|
- $userid = input('userid/d');
|
|
|
- $list = UserAuthsModel::where('userid',$userid)->order('id','asc')->append(['identitytype_text'])->select();
|
|
|
- $count = UserAuthsModel::where('userid',$userid)->count();
|
|
|
- if ($count==0){
|
|
|
- exit(json_encode(array(
|
|
|
- 'code' => 1,
|
|
|
- 'msg' => "未查询到数据"
|
|
|
- )));
|
|
|
- }
|
|
|
- exit(json_encode(array(
|
|
|
- 'code' => 0,
|
|
|
- 'msg' => "",
|
|
|
- 'count' => $count,
|
|
|
- 'data' => $list
|
|
|
- )));
|
|
|
- }
|
|
|
-
|
|
|
- public function delAuths()
|
|
|
- {
|
|
|
- $id = input('id/d');
|
|
|
- $auths = UserAuthsModel::find($id);
|
|
|
- if ($auths->identitytype == 'mobile'){
|
|
|
- exit(json_encode(array(
|
|
|
- 'code' => 1,
|
|
|
- 'msg' => "手机号授权方式不允许删除"
|
|
|
- )));
|
|
|
- }
|
|
|
- $result = $auths->delete();
|
|
|
- if ($result){
|
|
|
- exit(json_encode(array(
|
|
|
- 'code' => 0
|
|
|
- )));
|
|
|
- }
|
|
|
- exit(json_encode(array(
|
|
|
- 'code' => 1,
|
|
|
- 'msg' => "删除失败,请稍后重试"
|
|
|
- )));
|
|
|
- }
|
|
|
-
|
|
|
- // 用户
|
|
|
- public function userList()
|
|
|
- {
|
|
|
- $agentid = $this->access_agent['id'];
|
|
|
- $groupslist = UserGroupsModel::order(['isdefault'=>'desc','id'=>'asc'])->select();
|
|
|
- $brokerlist = BrokerModel::where('agentid', '=', $agentid)->order(['id'=>'desc'])->select();
|
|
|
- return view('user/userlist',[
|
|
|
- 'groupslist' => $groupslist,
|
|
|
- 'brokerlist' => $brokerlist
|
|
|
- ]);
|
|
|
- }
|
|
|
-
|
|
|
- public function userForm()
|
|
|
- {
|
|
|
- $agentid = $this->access_agent['id'];
|
|
|
- $brokeridarr = BrokerModel::where('agentid','=',$agentid)->column('id');
|
|
|
- $id = input('id/d', 0);
|
|
|
- $user = UserModel::whereIn('brokerid',$brokeridarr)->where('brokerid','<>', 0)->findOrEmpty($id);
|
|
|
- $agent = $this->access_agent;
|
|
|
- $groupslist = UserGroupsModel::order(['isdefault'=>'desc','id'=>'asc'])->select();
|
|
|
- $brokerlist = BrokerModel::where('agentid', '=', $agentid)->order(['id'=>'desc'])->select();
|
|
|
+
|
|
|
+ // 用户跟进记录
|
|
|
+ public function follow()
|
|
|
+ {
|
|
|
+ $userid = input('userid/d');
|
|
|
+ $user = UserModel::findOrEmpty($userid);
|
|
|
+ $followlist = UserFollowModel::where('userid', $userid)->order('id', 'desc')->limit(100)->select();
|
|
|
+ return view('user/follow', [
|
|
|
+ 'user' => $user,
|
|
|
+ 'followlist' => $followlist,
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function editFollow()
|
|
|
+ {
|
|
|
+ $userid = input('userid/d', 0);
|
|
|
+ $user = UserModel::findOrEmpty($userid);
|
|
|
+ if ($user->isEmpty()) {
|
|
|
+ exit(json_encode([
|
|
|
+ 'code' => 1,
|
|
|
+ 'msg' => "用户信息不存在。",
|
|
|
+ ]));
|
|
|
+ }
|
|
|
+ $agent = $this->access_agent;
|
|
|
+ $broker = BrokerModel::where('agentid', '=', $agent['id'])->findOrEmpty($user->brokerid);
|
|
|
+ if ($broker->isEmpty()) {
|
|
|
+ exit(json_encode([
|
|
|
+ 'code' => 1,
|
|
|
+ 'msg' => "你无权限上报该用户跟进记录。",
|
|
|
+ ]));
|
|
|
+ }
|
|
|
+ UserFollowModel::create([
|
|
|
+ 'userid' => $userid,
|
|
|
+ 'ftype' => input('ftype/s', ""),
|
|
|
+ 'remark' => input('remark/s', ""),
|
|
|
+ 'createtime' => time(),
|
|
|
+ ]);
|
|
|
+ $followstatus = input('followstatus/d', 1);
|
|
|
+ $user->save([
|
|
|
+ 'followstatus' => $followstatus,
|
|
|
+ ]);
|
|
|
+ exit(json_encode([
|
|
|
+ 'code' => 0,
|
|
|
+ ]));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 用户授权
|
|
|
+ public function authsList()
|
|
|
+ {
|
|
|
+ $userid = input('userid/d');
|
|
|
+ return view('user/authslist', [
|
|
|
+ 'userid' => $userid,
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function listAuths()
|
|
|
+ {
|
|
|
+ $userid = input('userid/d');
|
|
|
+ $list = UserAuthsModel::where('userid', $userid)->order('id', 'asc')->append(['identitytype_text'])->select();
|
|
|
+ $count = UserAuthsModel::where('userid', $userid)->count();
|
|
|
+ if ($count == 0) {
|
|
|
+ exit(json_encode([
|
|
|
+ 'code' => 1,
|
|
|
+ 'msg' => "未查询到数据",
|
|
|
+ ]));
|
|
|
+ }
|
|
|
+ exit(json_encode([
|
|
|
+ 'code' => 0,
|
|
|
+ 'msg' => "",
|
|
|
+ 'count' => $count,
|
|
|
+ 'data' => $list,
|
|
|
+ ]));
|
|
|
+ }
|
|
|
+
|
|
|
+ public function delAuths()
|
|
|
+ {
|
|
|
+ $id = input('id/d');
|
|
|
+ $auths = UserAuthsModel::find($id);
|
|
|
+ if ($auths->identitytype == 'mobile') {
|
|
|
+ exit(json_encode([
|
|
|
+ 'code' => 1,
|
|
|
+ 'msg' => "手机号授权方式不允许删除",
|
|
|
+ ]));
|
|
|
+ }
|
|
|
+ $result = $auths->delete();
|
|
|
+ if ($result) {
|
|
|
+ exit(json_encode([
|
|
|
+ 'code' => 0,
|
|
|
+ ]));
|
|
|
+ }
|
|
|
+ exit(json_encode([
|
|
|
+ 'code' => 1,
|
|
|
+ 'msg' => "删除失败,请稍后重试",
|
|
|
+ ]));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 用户
|
|
|
+ public function userList()
|
|
|
+ {
|
|
|
+ $agentid = $this->access_agent['id'];
|
|
|
+ $groupslist = UserGroupsModel::order(['isdefault' => 'desc', 'id' => 'asc'])->select();
|
|
|
+ $brokerlist = BrokerModel::where('agentid', '=', $agentid)->order(['id' => 'desc'])->select();
|
|
|
+ return view('user/userlist', [
|
|
|
+ 'groupslist' => $groupslist,
|
|
|
+ 'brokerlist' => $brokerlist,
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function userForm()
|
|
|
+ {
|
|
|
+ $agentid = $this->access_agent['id'];
|
|
|
+ $brokeridarr = BrokerModel::where('agentid', '=', $agentid)->column('id');
|
|
|
+ $id = input('id/d', 0);
|
|
|
+ $user = UserModel::whereIn('brokerid', $brokeridarr)->where('brokerid', '<>', 0)->findOrEmpty($id);
|
|
|
+ $agent = $this->access_agent;
|
|
|
+ $groupslist = UserGroupsModel::order(['isdefault' => 'desc', 'id' => 'asc'])->select();
|
|
|
+ $brokerlist = BrokerModel::where('agentid', '=', $agentid)->order(['id' => 'desc'])->select();
|
|
|
$willlist = UserWill::select();
|
|
|
$emptimelist = RensheCode::getList('emp_time');
|
|
|
$communitylist = RensheCode::getList('community')->toArray();
|
|
|
array_push($communitylist, ['code' => 0, 'id' => 0, 'name' => "不限"]);
|
|
|
$comlist = ComjobsCate::select();
|
|
|
- return view('user/userform',[
|
|
|
- 'brokerlist' => $brokerlist,
|
|
|
- 'groupslist' => $groupslist,
|
|
|
- 'agent' => $agent,
|
|
|
- 'user' => $user,
|
|
|
+ return view('user/userform', [
|
|
|
+ 'brokerlist' => $brokerlist,
|
|
|
+ 'groupslist' => $groupslist,
|
|
|
+ 'agent' => $agent,
|
|
|
+ 'user' => $user,
|
|
|
'willlist' => $willlist,
|
|
|
'emptimelist' => $emptimelist,
|
|
|
'communitylist' => $communitylist,
|
|
|
'comlist' => $comlist,
|
|
|
- ]);
|
|
|
- }
|
|
|
-
|
|
|
- public function fieldUser()
|
|
|
- {
|
|
|
- $agentid = $this->access_agent['id'];
|
|
|
- $brokeridarr = BrokerModel::where('agentid','=',$agentid)->column('id');
|
|
|
- $id = input('id/d',0);
|
|
|
- $user = UserModel::whereIn('brokerid',$brokeridarr)->where('brokerid','<>', 0)->findOrEmpty($id);
|
|
|
- if ($user->isEmpty()){
|
|
|
- exit(json_encode(array(
|
|
|
- 'code' => 1,
|
|
|
- 'msg' => "信息不存在"
|
|
|
- )));
|
|
|
- }else{
|
|
|
- $user->save([
|
|
|
- input('field/s') => input('value/s')
|
|
|
- ]);
|
|
|
- }
|
|
|
- exit(json_encode(array(
|
|
|
- 'code' => 0
|
|
|
- )));
|
|
|
- }
|
|
|
-
|
|
|
- public function listUser()
|
|
|
- {
|
|
|
- $agentid = $this->access_agent['id'];
|
|
|
- $limit = input('limit', 20);
|
|
|
- $page = input('page', 1);
|
|
|
- $map = array();
|
|
|
- $brokeridarr = BrokerModel::where('agentid','=',$agentid)->column('id');
|
|
|
- $map[] = ['brokerid', 'in', $brokeridarr];
|
|
|
- $map[] = ['brokerid', '<>', 0];
|
|
|
- $keywords = input('keywords/s');
|
|
|
- if (!empty($keywords)){
|
|
|
- $map[] =['nickname|realname|mobile', 'like', '%'.$keywords.'%', 'or'];
|
|
|
- }
|
|
|
- $groupsid = input('groupsid/d');
|
|
|
- if (!empty($groupsid)){
|
|
|
- $map[] = ['groupsid', '=', $groupsid];
|
|
|
- }
|
|
|
- $brokerid = input('brokerid/d');
|
|
|
- if (!empty($brokerid)){
|
|
|
- $map[] = ['brokerid', '=', $brokerid];
|
|
|
- }
|
|
|
- $status = input('status/d');
|
|
|
- if (!empty($status)){
|
|
|
- $map[] = ['status', '=', $status];
|
|
|
- }
|
|
|
- $authstatus = input('authstatus/d');
|
|
|
- if (!empty($authstatus)){
|
|
|
- $map[] = ['authstatus', '=', $authstatus];
|
|
|
- }
|
|
|
- $followstatus = input('followstatus/d');
|
|
|
- if (!empty($followstatus)){
|
|
|
- $map[] = ['followstatus', '=', $followstatus];
|
|
|
- }
|
|
|
- $list = UserModel::with(['userGroups','broker'])->where($map)->order('id','desc')->limit($limit)->page($page)->append(['status_text','isvip_text','authstatus_text','followstatus_text'])->select();
|
|
|
- $count = UserModel::where($map)->count();
|
|
|
- if ($count==0){
|
|
|
- exit(json_encode(array(
|
|
|
- 'code' => 1,
|
|
|
- 'msg' => "未查询到数据"
|
|
|
- )));
|
|
|
- }
|
|
|
- exit(json_encode(array(
|
|
|
- 'code' => 0,
|
|
|
- 'msg' => "",
|
|
|
- 'count' => $count,
|
|
|
- 'data' => $list
|
|
|
- )));
|
|
|
- }
|
|
|
-
|
|
|
- public function exportUser()
|
|
|
- {
|
|
|
- $agentid = $this->access_agent['id'];
|
|
|
- $map = array();
|
|
|
- $brokeridarr = BrokerModel::where('agentid','=',$agentid)->column('id');
|
|
|
- $map[] = ['brokerid', 'in', $brokeridarr];
|
|
|
- $map[] = ['brokerid', '<>', 0];
|
|
|
- $keywords = input('keywords/s');
|
|
|
- if (!empty($keywords)){
|
|
|
- $map[] =['nickname|realname|mobile', 'like', '%'.$keywords.'%', 'or'];
|
|
|
- }
|
|
|
- $groupsid = input('groupsid/d');
|
|
|
- if (!empty($groupsid)){
|
|
|
- $map[] = ['groupsid', '=', $groupsid];
|
|
|
- }
|
|
|
- $brokerid = input('brokerid/d');
|
|
|
- if (!empty($brokerid)){
|
|
|
- $map[] = ['brokerid', '=', $brokerid];
|
|
|
- }
|
|
|
- $status = input('status/d');
|
|
|
- if (!empty($status)){
|
|
|
- $map[] = ['status', '=', $status];
|
|
|
- }
|
|
|
- $authstatus = input('authstatus/d');
|
|
|
- if (!empty($authstatus)){
|
|
|
- $map[] = ['authstatus', '=', $authstatus];
|
|
|
- }
|
|
|
- $followstatus = input('followstatus/d');
|
|
|
- if (!empty($followstatus)){
|
|
|
- $map[] = ['followstatus', '=', $followstatus];
|
|
|
- }
|
|
|
- $xlsData = UserModel::with(['userGroups','broker'])->where($map)->order('id','desc')->append(['status_text','isvip_text','authstatus_text','followstatus_text'])->select()->toArray();
|
|
|
- $xlsCell = array(
|
|
|
- array('id','表ID'),
|
|
|
- array('nickname','昵称'),
|
|
|
- array('realname','姓名'),
|
|
|
- array('mobile','手机号'),
|
|
|
- array('status_text','状态'),
|
|
|
- array('isvip_text','是否VIP'),
|
|
|
- array('authstatus_text','是否实名认证'),
|
|
|
- array('idcard','身份证号'),
|
|
|
- array('gender','性别',array(1=>'男',2=>'女')),
|
|
|
- array('birthday','出生日期'),
|
|
|
- array('address','现居住地'),
|
|
|
- array('education','学历'),
|
|
|
- array('bankcard.openbank','开户行'),
|
|
|
- array('bankcard.account','账户名'),
|
|
|
- array('bankcard.number','账户号'),
|
|
|
- array('followstatus_text','跟进状态'),
|
|
|
- array('userGroups.title','用户组'),
|
|
|
- array('broker.title','职业顾问'),
|
|
|
- array('createtime','注册时间'),
|
|
|
- );
|
|
|
- export_excel("系统用户",$xlsCell,$xlsData);
|
|
|
- }
|
|
|
-
|
|
|
- public function editUser()
|
|
|
- {
|
|
|
- $id = input('id/d');
|
|
|
- $mobile = input('mobile/s');
|
|
|
- $vdata = array(
|
|
|
- 'id' => $id,
|
|
|
- 'mobile' => $mobile
|
|
|
- );
|
|
|
- try {
|
|
|
- validate(UserValidate::class)->check($vdata);
|
|
|
- } catch (ValidateException $e) {
|
|
|
- exit(json_encode(array(
|
|
|
- 'code' => 1,
|
|
|
- 'msg' => $e->getError()
|
|
|
- )));
|
|
|
- }
|
|
|
- $data = array(
|
|
|
- 'groupsid' => input('groupsid/d', 0),
|
|
|
- 'brokerid' => input('brokerid/d', 0),
|
|
|
- 'nickname' => input('nickname/s', ""),
|
|
|
- 'avatar' => input('avatar/s', ""),
|
|
|
- 'realname' => input('realname/s', ""),
|
|
|
- 'mobile' => $mobile,
|
|
|
- 'status' => input('status/d', 1),
|
|
|
- 'isvip' => input('isvip/d', 1),
|
|
|
- 'authstatus' => input('authstatus/d', 1),
|
|
|
- 'authremark' => input('authremark/s', ""),
|
|
|
- 'idcardzpic' => input('idcardzpic/s', ""),
|
|
|
- 'idcardfpic' => input('idcardfpic/s', ""),
|
|
|
- 'idcard' => input('idcard/s', ""),
|
|
|
- 'gender' => input('gender/d', 1),
|
|
|
- 'birthday' => input('birthday/s', ""),
|
|
|
- 'address' => input('address/s', ""),
|
|
|
- 'education' => input('education/s', ""),
|
|
|
- 'jobintention' => input('jobintention/s', ""),
|
|
|
- 'workexperience' => input('workexperience/s', ""),
|
|
|
- 'eduexperience' => input('eduexperience/s', ""),
|
|
|
- 'followstatus' => input('followstatus/d', 1),
|
|
|
- 'bankcard' => input('bankcard/a', array()),
|
|
|
- );
|
|
|
- $password = input('password/s');
|
|
|
- if (empty($id)){
|
|
|
- $data['integral'] = 0;
|
|
|
- $data['inttotal'] = 0;
|
|
|
- $data['createtime'] = time();
|
|
|
- $user = UserModel::create($data);
|
|
|
- $auths = UserAuthsModel::create([
|
|
|
- 'userid' => $user->id,
|
|
|
- 'identitytype' => "mobile",
|
|
|
- 'identifier' => $mobile,
|
|
|
- 'password' => empty($password) ? md5("123456789") : md5($password),
|
|
|
- 'logintime' => time(),
|
|
|
- 'loginip' => $_SERVER['SERVER_ADDR'],
|
|
|
- 'wxampcode' => ""
|
|
|
- ]);
|
|
|
- }else{
|
|
|
- $data['id'] = $id;
|
|
|
- $user = UserModel::update($data);
|
|
|
- $adata = ['identifier'=>$mobile];
|
|
|
- if (!empty($password)){
|
|
|
- $adata['password'] = md5($password);
|
|
|
- }
|
|
|
- UserAuthsModel::update($adata, ['userid'=>$id,'identitytype'=>'mobile']);
|
|
|
- }
|
|
|
- exit(json_encode(array(
|
|
|
- 'code' => 0
|
|
|
- )));
|
|
|
- }
|
|
|
-
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function fieldUser()
|
|
|
+ {
|
|
|
+ $agentid = $this->access_agent['id'];
|
|
|
+ $brokeridarr = BrokerModel::where('agentid', '=', $agentid)->column('id');
|
|
|
+ $id = input('id/d', 0);
|
|
|
+ $user = UserModel::whereIn('brokerid', $brokeridarr)->where('brokerid', '<>', 0)->findOrEmpty($id);
|
|
|
+ if ($user->isEmpty()) {
|
|
|
+ exit(json_encode([
|
|
|
+ 'code' => 1,
|
|
|
+ 'msg' => "信息不存在",
|
|
|
+ ]));
|
|
|
+ } else {
|
|
|
+ $user->save([
|
|
|
+ input('field/s') => input('value/s'),
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ exit(json_encode([
|
|
|
+ 'code' => 0,
|
|
|
+ ]));
|
|
|
+ }
|
|
|
+
|
|
|
+ public function listUser()
|
|
|
+ {
|
|
|
+ $agentid = $this->access_agent['id'];
|
|
|
+ $limit = input('limit', 20);
|
|
|
+ $page = input('page', 1);
|
|
|
+ $map = [];
|
|
|
+ $brokeridarr = BrokerModel::where('agentid', '=', $agentid)->column('id');
|
|
|
+ if (!empty($brokeridarr)) {
|
|
|
+ $map[] = ['brokerid', 'in', $brokeridarr];
|
|
|
+ } else {
|
|
|
+ $map[] = ['brokerid', '=', -1];
|
|
|
+ }
|
|
|
+ $keywords = input('keywords/s');
|
|
|
+ if (!empty($keywords)) {
|
|
|
+ $map[] = ['nickname|realname|mobile', 'like', '%' . $keywords . '%', 'or'];
|
|
|
+ }
|
|
|
+ $groupsid = input('groupsid/d');
|
|
|
+ if (!empty($groupsid)) {
|
|
|
+ $map[] = ['groupsid', '=', $groupsid];
|
|
|
+ }
|
|
|
+ $brokerid = input('brokerid/d');
|
|
|
+ if (!empty($brokerid)) {
|
|
|
+ $map[] = ['brokerid', '=', $brokerid];
|
|
|
+ }
|
|
|
+ $status = input('status/d');
|
|
|
+ if (!empty($status)) {
|
|
|
+ $map[] = ['status', '=', $status];
|
|
|
+ }
|
|
|
+ $authstatus = input('authstatus/d');
|
|
|
+ if (!empty($authstatus)) {
|
|
|
+ $map[] = ['authstatus', '=', $authstatus];
|
|
|
+ }
|
|
|
+ $followstatus = input('followstatus/d');
|
|
|
+ if (!empty($followstatus)) {
|
|
|
+ $map[] = ['followstatus', '=', $followstatus];
|
|
|
+ }
|
|
|
+ $list = UserModel::with(['userGroups', 'broker'])->where($map)->order('id', 'desc')->limit($limit)->page($page)->append(['status_text', 'isvip_text', 'authstatus_text', 'followstatus_text'])->select();
|
|
|
+ $count = UserModel::where($map)->count();
|
|
|
+ if ($count == 0) {
|
|
|
+ exit(json_encode([
|
|
|
+ 'code' => 1,
|
|
|
+ 'msg' => "未查询到数据",
|
|
|
+ ]));
|
|
|
+ }
|
|
|
+ exit(json_encode([
|
|
|
+ 'code' => 0,
|
|
|
+ 'msg' => "",
|
|
|
+ 'count' => $count,
|
|
|
+ 'data' => $list,
|
|
|
+ ]));
|
|
|
+ }
|
|
|
+
|
|
|
+ public function exportUser()
|
|
|
+ {
|
|
|
+ $agentid = $this->access_agent['id'];
|
|
|
+ $map = [];
|
|
|
+ $brokeridarr = BrokerModel::where('agentid', '=', $agentid)->column('id');
|
|
|
+ $map[] = ['brokerid', 'in', $brokeridarr];
|
|
|
+ $map[] = ['brokerid', '<>', 0];
|
|
|
+ $keywords = input('keywords/s');
|
|
|
+ if (!empty($keywords)) {
|
|
|
+ $map[] = ['nickname|realname|mobile', 'like', '%' . $keywords . '%', 'or'];
|
|
|
+ }
|
|
|
+ $groupsid = input('groupsid/d');
|
|
|
+ if (!empty($groupsid)) {
|
|
|
+ $map[] = ['groupsid', '=', $groupsid];
|
|
|
+ }
|
|
|
+ $brokerid = input('brokerid/d');
|
|
|
+ if (!empty($brokerid)) {
|
|
|
+ $map[] = ['brokerid', '=', $brokerid];
|
|
|
+ }
|
|
|
+ $status = input('status/d');
|
|
|
+ if (!empty($status)) {
|
|
|
+ $map[] = ['status', '=', $status];
|
|
|
+ }
|
|
|
+ $authstatus = input('authstatus/d');
|
|
|
+ if (!empty($authstatus)) {
|
|
|
+ $map[] = ['authstatus', '=', $authstatus];
|
|
|
+ }
|
|
|
+ $followstatus = input('followstatus/d');
|
|
|
+ if (!empty($followstatus)) {
|
|
|
+ $map[] = ['followstatus', '=', $followstatus];
|
|
|
+ }
|
|
|
+ $xlsData = UserModel::with(['userGroups', 'broker'])->where($map)->order('id', 'desc')->append(['status_text', 'isvip_text', 'authstatus_text', 'followstatus_text'])->select()->toArray();
|
|
|
+ $xlsCell = [
|
|
|
+ ['id', '表ID'],
|
|
|
+ ['nickname', '昵称'],
|
|
|
+ ['realname', '姓名'],
|
|
|
+ ['mobile', '手机号'],
|
|
|
+ ['status_text', '状态'],
|
|
|
+ ['isvip_text', '是否VIP'],
|
|
|
+ ['authstatus_text', '是否实名认证'],
|
|
|
+ ['idcard', '身份证号'],
|
|
|
+ ['gender', '性别', [1 => '男', 2 => '女']],
|
|
|
+ ['birthday', '出生日期'],
|
|
|
+ ['address', '现居住地'],
|
|
|
+ ['education', '学历'],
|
|
|
+ ['bankcard.openbank', '开户行'],
|
|
|
+ ['bankcard.account', '账户名'],
|
|
|
+ ['bankcard.number', '账户号'],
|
|
|
+ ['followstatus_text', '跟进状态'],
|
|
|
+ ['userGroups.title', '用户组'],
|
|
|
+ ['broker.title', '职业顾问'],
|
|
|
+ ['createtime', '注册时间'],
|
|
|
+ ];
|
|
|
+ export_excel("系统用户", $xlsCell, $xlsData);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function editUser()
|
|
|
+ {
|
|
|
+ $id = input('id/d');
|
|
|
+ $mobile = input('mobile/s');
|
|
|
+ $vdata = [
|
|
|
+ 'id' => $id,
|
|
|
+ 'mobile' => $mobile,
|
|
|
+ ];
|
|
|
+ try {
|
|
|
+ validate(UserValidate::class)->check($vdata);
|
|
|
+ } catch (ValidateException $e) {
|
|
|
+ exit(json_encode([
|
|
|
+ 'code' => 1,
|
|
|
+ 'msg' => $e->getError(),
|
|
|
+ ]));
|
|
|
+ }
|
|
|
+ $data = [
|
|
|
+ 'groupsid' => input('groupsid/d', 0),
|
|
|
+ 'brokerid' => input('brokerid/d', 0),
|
|
|
+ 'nickname' => input('nickname/s', ""),
|
|
|
+ 'avatar' => input('avatar/s', ""),
|
|
|
+ 'realname' => input('realname/s', ""),
|
|
|
+ 'mobile' => $mobile,
|
|
|
+ 'status' => input('status/d', 1),
|
|
|
+ 'isvip' => input('isvip/d', 1),
|
|
|
+ 'authstatus' => input('authstatus/d', 1),
|
|
|
+ 'authremark' => input('authremark/s', ""),
|
|
|
+ 'idcardzpic' => input('idcardzpic/s', ""),
|
|
|
+ 'idcardfpic' => input('idcardfpic/s', ""),
|
|
|
+ 'idcard' => input('idcard/s', ""),
|
|
|
+ 'gender' => input('gender/d', 1),
|
|
|
+ 'birthday' => input('birthday/s', ""),
|
|
|
+ 'address' => input('address/s', ""),
|
|
|
+ 'education' => input('education/s', ""),
|
|
|
+ 'jobintention' => input('jobintention/s', ""),
|
|
|
+ 'workexperience' => input('workexperience/s', ""),
|
|
|
+ 'eduexperience' => input('eduexperience/s', ""),
|
|
|
+ 'followstatus' => input('followstatus/d', 1),
|
|
|
+ 'bankcard' => input('bankcard/a', []),
|
|
|
+ ];
|
|
|
+ $password = input('password/s');
|
|
|
+ if (empty($id)) {
|
|
|
+ $data['integral'] = 0;
|
|
|
+ $data['inttotal'] = 0;
|
|
|
+ $data['createtime'] = time();
|
|
|
+ $user = UserModel::create($data);
|
|
|
+ $auths = UserAuthsModel::create([
|
|
|
+ 'userid' => $user->id,
|
|
|
+ 'identitytype' => "mobile",
|
|
|
+ 'identifier' => $mobile,
|
|
|
+ 'password' => empty($password) ? md5("123456789") : md5($password),
|
|
|
+ 'logintime' => time(),
|
|
|
+ 'loginip' => $_SERVER['SERVER_ADDR'],
|
|
|
+ 'wxampcode' => "",
|
|
|
+ ]);
|
|
|
+ } else {
|
|
|
+ $data['id'] = $id;
|
|
|
+ $user = UserModel::update($data);
|
|
|
+ $adata = ['identifier' => $mobile];
|
|
|
+ if (!empty($password)) {
|
|
|
+ $adata['password'] = md5($password);
|
|
|
+ }
|
|
|
+ UserAuthsModel::update($adata, ['userid' => $id, 'identitytype' => 'mobile']);
|
|
|
+ }
|
|
|
+ exit(json_encode([
|
|
|
+ 'code' => 0,
|
|
|
+ ]));
|
|
|
+ }
|
|
|
|
|
|
|
|
|
}
|