Commit 2eb1fc11 authored by hujun's avatar hujun

获取默认城市和站点

parent 330b620c
......@@ -11,6 +11,7 @@ namespace app\index\extend;
*/
use app\extra\RedisExt;
use app\model\AAgents;
use app\model\ASite;
use app\model\GHousesToAgents;
use app\model\GOperatingRecords;
use app\model\Users;
......@@ -290,6 +291,7 @@ class Basic extends Controller
$result = $records->record($agents_id, $type, $remark, '',$user_id);
return $result;
}
/**
* 默认城市选择
* @param $agentId
......@@ -303,11 +305,25 @@ class Basic extends Controller
$this->siteId = $redis_->get("agent_site_id_" . $agentId);
}
if(empty($this->city) || empty($this->siteId)){
//取数据库
$this->city = "上海市";
$this->siteId = "10001";
$m_agent = new AAgents();
$m_site = new ASite();
$site_id = $m_agent->getAgentsById($agentId, 'site_id');
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;
}
}
} catch (Exception $exception) {
} catch (\Exception $exception) {
echo json_encode(array( "code" => "300", "msg" => $exception, "data" => [], "type" => "json" ));
exit;
}
......
......@@ -48,4 +48,17 @@ class ASite extends BaseModel
}
/**
* 根据id获取单个字段值
*
* @param $id
* @param $fields
* @return mixed
*/
public function getSiteById($id, $fields)
{
$return = $this->where('id', $id)->value($fields);
return $return;
}
}
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