|
@@ -3,7 +3,7 @@
|
|
|
namespace app\common\library;
|
|
|
|
|
|
use app\common\model\CompanyStaff;
|
|
|
-use app\common\model\Company as User;
|
|
|
+use app\common\model\Company;
|
|
|
use app\common\model\UserRule;
|
|
|
use fast\Random;
|
|
|
use think\Config;
|
|
@@ -27,7 +27,8 @@ class Authcompany
|
|
|
//默认配置
|
|
|
protected $config = [];
|
|
|
protected $options = [];
|
|
|
- protected $allowFields = ['id', 'name', 'logo','image','contacts', 'mobile','province_name','city_name','area_name','province_id','city_id','area_id','address','full_address','longitude','latitude','aptitude_images','open_hours','staff'];
|
|
|
+ //protected $allowFields = ['id', 'name', 'logo','image','contacts', 'mobile','province_name','city_name','area_name','province_id','city_id','area_id','address','full_address','longitude','latitude','aptitude_images','open_hours','staff'];
|
|
|
+ protected $allowFields = ['id','company_id','type','truename','mobile','company'];
|
|
|
|
|
|
|
|
|
public function __construct($options = [])
|
|
@@ -112,15 +113,28 @@ class Authcompany
|
|
|
}
|
|
|
$user_id = intval($data['user_id']);
|
|
|
if ($user_id > 0) {
|
|
|
- $user = User::get($user_id);
|
|
|
+ $user = CompanyStaff::get($user_id);
|
|
|
if (!$user) {
|
|
|
$this->setError('Account not exist');
|
|
|
return false;
|
|
|
}
|
|
|
- /*if ($user['status'] != 1) {
|
|
|
+ if ($user->status != 1) {
|
|
|
$this->setError('Account is locked');
|
|
|
return false;
|
|
|
- }*/
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!$user->company_id){
|
|
|
+ $this->setError('Account not exist');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ $companyinfo = Company::get($user->company_id);
|
|
|
+ if(!$companyinfo){
|
|
|
+ $this->setError('Account not exist');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ $user->company = $companyinfo;
|
|
|
+
|
|
|
$this->_user = $user;
|
|
|
$this->_logined = true;
|
|
|
$this->_token = $token;
|
|
@@ -319,9 +333,8 @@ class Authcompany
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- //直接登录会员
|
|
|
- return $this->direct($user->company_id,$user);
|
|
|
-
|
|
|
+ //直接登录员工
|
|
|
+ return $this->direct($user->id);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -386,32 +399,22 @@ class Authcompany
|
|
|
* @param int $user_id
|
|
|
* @return boolean
|
|
|
*/
|
|
|
- public function direct($user_id,$staff)
|
|
|
+ public function direct($staff_id)
|
|
|
{
|
|
|
- $user = User::get($user_id);
|
|
|
+ $user = CompanyStaff::get($staff_id);
|
|
|
if ($user) {
|
|
|
+ if(!$user->company_id){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ $companyinfo = Company::get($user->company_id);
|
|
|
+ if(!$companyinfo){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
- /*
|
|
|
- $ip = request()->ip();
|
|
|
- $time = time();
|
|
|
-
|
|
|
- //判断连续登录和最大连续登录
|
|
|
- if ($user->logintime < \fast\Date::unixtime('day')) {
|
|
|
- $user->successions = $user->logintime < \fast\Date::unixtime('day', -1) ? 1 : $user->successions + 1;
|
|
|
- $user->maxsuccessions = max($user->successions, $user->maxsuccessions);
|
|
|
- }
|
|
|
-
|
|
|
- $user->prevtime = $user->logintime;
|
|
|
- //记录本次登录的IP和时间
|
|
|
- $user->loginip = $ip;
|
|
|
- $user->logintime = $time;
|
|
|
- //重置登录失败次数
|
|
|
- $user->loginfailure = 0;
|
|
|
-
|
|
|
- $user->save();*/
|
|
|
|
|
|
- $user->staff = $staff;// 追加员工
|
|
|
+ $user->company = $companyinfo;// 追加公司
|
|
|
|
|
|
$this->_user = $user;
|
|
|
|
|
@@ -488,8 +491,8 @@ class Authcompany
|
|
|
$userinfo = array_merge($userinfo, Tokencompany::get($this->_token));
|
|
|
|
|
|
//追加
|
|
|
- $userinfo['image'] = one_domain_image($userinfo['image']);
|
|
|
- $userinfo['money'] = model('walletcompany')->getWallet($this->id,'money');
|
|
|
+ $userinfo['company']['image'] = one_domain_image($userinfo['company']['image']);
|
|
|
+ $userinfo['money'] = model('walletcompany')->getWallet($this->company_id,'money');
|
|
|
|
|
|
return $userinfo;
|
|
|
}
|