Commit 585d8a5b authored by hujun's avatar hujun

通过token获取用户信息

parent 713a59ee
...@@ -364,8 +364,10 @@ class Broker extends Basic ...@@ -364,8 +364,10 @@ class Broker extends Basic
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getAgentsByPhone() { public function getAgentsByPhone() {
$data = $this->a_agents->getInfo($this->params['phone']); $agents = new Agents();
$data = $agents->getInfo($this->params['phone']);
$data['openid'] = ""; $data['openid'] = "";
$data['token'] = $this->authToken;
return $this->response(200, "", $data); return $this->response(200, "", $data);
} }
} }
\ No newline at end of file
...@@ -215,5 +215,46 @@ class Agents extends Model ...@@ -215,5 +215,46 @@ class Agents extends Model
->field('realname,phone,head_portrait,agentshopname') ->field('realname,phone,head_portrait,agentshopname')
->find(); ->find();
} }
/**
* 返回经纪人和部门信息
*
* @return array|false|\PDOStatement|string|\think\Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getInfo($phone) {
$agents_data = $this->where([
'phone' => $phone,
'inuse' => 1,
'level' => ['in','2,5']
])->find();
if (!empty($agents_data->store_id)) {
$store_name = Db::table('a_store')->where('id',$agents_data['store_id'])->value('store_name');
$agents_data['department'] = $store_name;
}
if (!empty($agents_data->auth_group_id)) {
$district_name = Db::table('a_district')->where('id',$agents_data['district_id'])->value('district_name');
$agents_data['department'] = $agents_data['department'] ? $district_name.'-'.$store_name : $district_name;
}
$agents_data['commission'] = 500;
switch ($agents_data['level']) {
case 10 :
$agents_data['level_name'] = '业务员';break;
case 20 :
$agents_data['level_name'] = '店长';break;
case 30 :
$agents_data['level_name'] = '总监';break;
case 40 :
$agents_data['level_name'] = '总监';break;
}
return $agents_data;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment