Commit 3e65d793 authored by hujun's avatar hujun

2

parent 10f3dfd1
...@@ -118,7 +118,7 @@ class Basic extends Controller ...@@ -118,7 +118,7 @@ class Basic extends Controller
*/ */
public function getCity($agentId) public function getCity($agentId)
{ {
if (empty($this->userId)) { if (empty($agentId)) {
return ; //没有登陆 return ; //没有登陆
} }
...@@ -130,22 +130,15 @@ class Basic extends Controller ...@@ -130,22 +130,15 @@ class Basic extends Controller
} }
if(empty($this->city) || empty($this->siteId)){ if(empty($this->city) || empty($this->siteId)){
$m_agent = new AAgents(); $m_agent = new AAgents();
$m_site = new ASite(); $site_city = $m_agent->getAgentsSite(['a.id'=>$agentId], 'a.site_id,b.city');
$site_id = $m_agent->getAgentsById($agentId, 'site_id'); if (empty($site_city['city']) || empty($site_city['site_id'])) {
echo json_encode(array( "code" => "300", "msg" => '账号位置信息错误,请联系运营', "data" => [], "type" => "json" ));
if ($site_id) {
$this->siteId = $site_id;
$city = $m_site->getSiteById($site_id, 'city');
if ($city) {
$this->city = $city;
} else {
echo json_encode(array( "code" => "300", "msg" => '账号位置信息错误,请联系运营', "data" => [], "type" => "json" ));
exit;
}
} else {
echo json_encode(array( "code" => "300", "msg" => '账号位置信息错误,请联系运营', "data" => [], "type" => "json" ));
exit; exit;
} else {
$this->city = $site_city['city'];
$this->siteId = $site_city['site_id'];
} }
} }
} catch (Exception $exception) { } catch (Exception $exception) {
echo json_encode(array( "code" => "300", "msg" => $exception, "data" => [], "type" => "json" )); echo json_encode(array( "code" => "300", "msg" => $exception, "data" => [], "type" => "json" ));
......
...@@ -1365,4 +1365,21 @@ class AAgents extends BaseModel ...@@ -1365,4 +1365,21 @@ class AAgents extends BaseModel
return $id; return $id;
} }
/**
* @param $where
* @param $fields
* @return array|false|\PDOStatement|string|\think\Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getAgentsSite($where, $fields)
{
return $this->alias('a')
->field($fields)
->join('a_site b', 'a.site_id=b.id', 'left')
->where($where)
->find();
}
} }
\ No newline at end of file
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