|
@@ -2,8 +2,7 @@
|
|
|
|
|
|
namespace app\common\library;
|
|
|
|
|
|
-use app\common\model\CompanyStaff;
|
|
|
-use app\common\model\Company;
|
|
|
+use app\common\model\Coach;
|
|
|
use app\common\model\UserRule;
|
|
|
use fast\Random;
|
|
|
use think\Config;
|
|
@@ -13,7 +12,7 @@ use think\Hook;
|
|
|
use think\Request;
|
|
|
use think\Validate;
|
|
|
|
|
|
-class Authcompany
|
|
|
+class Authcoach
|
|
|
{
|
|
|
protected static $instance = null;
|
|
|
protected $_error = '';
|
|
@@ -28,12 +27,12 @@ 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','company_id','type','truename','mobile','company'];
|
|
|
+ protected $allowFields = ['id','type','truename','mobile'];
|
|
|
|
|
|
|
|
|
public function __construct($options = [])
|
|
|
{
|
|
|
- if ($config = Config::get('company')) {
|
|
|
+ if ($config = Config::get('coach')) {
|
|
|
$this->config = array_merge($this->config, $config);
|
|
|
}
|
|
|
$this->options = array_merge($this->config, $options);
|
|
@@ -107,13 +106,13 @@ class Authcompany
|
|
|
if ($this->_error) {
|
|
|
return false;
|
|
|
}
|
|
|
- $data = Tokencompany::get($token);
|
|
|
+ $data = Tokencoach::get($token);
|
|
|
if (!$data) {
|
|
|
return false;
|
|
|
}
|
|
|
$user_id = intval($data['user_id']);
|
|
|
if ($user_id > 0) {
|
|
|
- $user = CompanyStaff::get($user_id);
|
|
|
+ $user = Coach::get($user_id);
|
|
|
if (!$user) {
|
|
|
$this->setError('Account not exist');
|
|
|
return false;
|
|
@@ -123,7 +122,7 @@ class Authcompany
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- if(!$user->company_id){
|
|
|
+ /* if(!$user->company_id){
|
|
|
$this->setError('Account not exist');
|
|
|
return false;
|
|
|
}
|
|
@@ -133,14 +132,14 @@ class Authcompany
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- $user->company = $companyinfo;
|
|
|
+ $user->company = $companyinfo;*/
|
|
|
|
|
|
$this->_user = $user;
|
|
|
$this->_logined = true;
|
|
|
$this->_token = $token;
|
|
|
|
|
|
//初始化成功的事件
|
|
|
- Hook::listen("company_init_successed", $this->_user);
|
|
|
+// Hook::listen("company_init_successed", $this->_user);
|
|
|
|
|
|
return true;
|
|
|
} else {
|
|
@@ -160,7 +159,7 @@ class Authcompany
|
|
|
public function login($account, $password, $openid)
|
|
|
{
|
|
|
$field = 'mobile';
|
|
|
- $user = CompanyStaff::get([$field => $account]);
|
|
|
+ $user = Coach::get([$field => $account]);
|
|
|
if (!$user) {
|
|
|
$this->setError('Account is incorrect');
|
|
|
return false;
|
|
@@ -193,7 +192,7 @@ class Authcompany
|
|
|
//设置登录标识
|
|
|
$this->_logined = false;
|
|
|
//删除Token
|
|
|
- Tokencompany::delete($this->_token);
|
|
|
+ Tokencoach::delete($this->_token);
|
|
|
//退出成功的事件
|
|
|
Hook::listen("user_logout_successed", $this->_user);
|
|
|
return true;
|
|
@@ -217,10 +216,10 @@ class Authcompany
|
|
|
|
|
|
$salt = Random::alnum();
|
|
|
$newpassword = $this->getEncryptPassword($newpassword, $salt);
|
|
|
- unset($this->_user['company']);
|
|
|
+ //unset($this->_user['company']);
|
|
|
$this->_user->save(['password' => $newpassword, 'salt' => $salt]);
|
|
|
|
|
|
- Tokencompany::delete($this->_token);
|
|
|
+ Tokencoach::delete($this->_token);
|
|
|
|
|
|
//同步到admin
|
|
|
$admin = [
|
|
@@ -329,9 +328,6 @@ class Authcompany
|
|
|
|
|
|
//追加
|
|
|
$userinfo['company']['image'] = one_domain_image($userinfo['company']['image']);
|
|
|
- $userinfo['money'] = model('walletcompany')->getWallet($this->company_id,'money'); //可提现金额
|
|
|
- $userinfo['dongjie_money'] = Db::name('order')->where('company_id',$this->company_id)->where('status',2)->where('ordertype',3)->sum('pay_fee');//冻结金额,即出售的套餐,但没使用的
|
|
|
- $userinfo['all_money'] = bcadd($userinfo['money'],$userinfo['dongjie_money'],2);
|
|
|
|
|
|
/////////////////////////////////////
|
|
|
//个人信息
|
|
@@ -340,65 +336,6 @@ class Authcompany
|
|
|
|
|
|
|
|
|
|
|
|
- //今日开单
|
|
|
- $map = [
|
|
|
- 'company_id' => $this->company_id,
|
|
|
- 'finish_time' => ['BETWEEN',[$strattime,$endtime]], //开单时间用完成时间
|
|
|
- 'status' => 3,
|
|
|
- ];
|
|
|
- if($this->type == 2){
|
|
|
- //员工的
|
|
|
- $map['staff_id'] = $this->id;
|
|
|
- }
|
|
|
-
|
|
|
- $userinfo['today_order_totalfee'] = Db::name('order')->where($map)->sum('total_fee');;
|
|
|
-
|
|
|
- //今日新增客户
|
|
|
- $map = [
|
|
|
- 'company_id' => $this->company_id,
|
|
|
- 'createtime'=>['BETWEEN',[$strattime,$endtime]],
|
|
|
- ];
|
|
|
- if($this->type == 2){
|
|
|
- //员工的
|
|
|
- $map['staff_id'] = $this->id;
|
|
|
- }
|
|
|
- $userinfo['today_newcus'] = Db::name('user_wallet')->where($map)->count();
|
|
|
-
|
|
|
- //今日新增预约
|
|
|
- $map = [
|
|
|
- 'company_id' => $this->company_id,
|
|
|
- 'createtime'=>['BETWEEN',[$strattime,$endtime]],
|
|
|
- ];
|
|
|
- $userinfo['today_newpre'] = Db::name('pre_order')->where($map)->count();
|
|
|
-
|
|
|
- //已接单订单数量
|
|
|
- $map = [
|
|
|
- 'company_id' => $this->company_id,
|
|
|
- 'status' => 2,
|
|
|
- ];
|
|
|
- $userinfo['order_unfinish'] = Db::name('order')->where($map)->count();
|
|
|
-
|
|
|
- //昨日订单数量
|
|
|
- $starttime = strtotime(date('Y-m-d')) - 86400;
|
|
|
- $endtime = strtotime(date('Y-m-d')) - 1;
|
|
|
- $map = [
|
|
|
- 'company_id' => $this->company_id,
|
|
|
- 'status' => 3,
|
|
|
- 'finish_time'=> ['BETWEEN',[$starttime,$endtime]],
|
|
|
- ];
|
|
|
- $userinfo['order_zuori'] = Db::name('order')->where($map)->count();
|
|
|
-
|
|
|
- //7日订单数量
|
|
|
- $starttime = strtotime(date('Y-m-d')) - 86400*6;
|
|
|
- $endtime = strtotime(date('Y-m-d')) + 86399;
|
|
|
- $map = [
|
|
|
- 'company_id' => $this->company_id,
|
|
|
- 'status' => 3,
|
|
|
- 'finish_time'=> ['BETWEEN',[$starttime,$endtime]],
|
|
|
- ];
|
|
|
- $userinfo['order_qiri'] = Db::name('order')->where($map)->count();
|
|
|
-
|
|
|
-
|
|
|
return $userinfo;
|
|
|
}
|
|
|
|