Commit 6c4c92ca authored by hujun's avatar hujun

查询定位图

parent 940f953f
......@@ -7,6 +7,7 @@ use app\api_broker\service\LocationService;
use app\api_broker\service\RedisCacheService;
use app\extra\RedisExt;
use app\index\service\PositionService;
use app\model\AAgents;
use app\model\ALocationListModel;
use think\Request;
......@@ -62,7 +63,7 @@ class Location extends Basic
*/
public function addLocation()
{
$code = 101;
$code = 101;
$params = &$this->params;
if (!isset($params['longitude']) || !isset($params['latitude']) ||
!isset($params['source'])
......@@ -83,4 +84,50 @@ class Location extends Basic
$msg = $result['msg'];
return $this->response($code, $msg);
}
/**
* 查询定位图
*
* @return \think\Response
*/
public function getLocationList()
{
$params = &$this->params;
if (empty($params['location_date'])) {
return $this->response(101, '日期时间错误');
} else {
$where['location_date'] = date('Y-m-d', strtotime($params['location_date']));
}
$s_redis = new RedisCacheService();
switch ($params['type']) {
case 1 :
if (empty($params['agent_name'])) {
return $this->response(101, '查询人参数错误');
}
$m_agent = new AAgents();
$agent_where['name'] = ['like', '%'.$params['agent_name'].'%'];
$agent_id = $m_agent->getFieldOneValue('id', $where);
if (empty($agent_id)) {
return $this->response(101, '没有该经纪人');
}
$where['agent_id'] = $agent_id;
$agent_data = $s_redis->getRedisCache(2, $this->agentId);
$is_ = $s_redis->checkRule($this->agentId, 'location_district'); //全公司的
if ($is_) {
$where['district_id'] = $agent_data['district_id']; //本部门
$is_ = $s_redis->checkRule($this->agentId, 'location_store'); //全门店
if ($is_) {
$where['store_id'] = $agent_data['store_id']; //本门店
}
}
break;
default :
$where['agent_id'] = $this->agentId; //默认查询自己
}
$m_location = new ALocationListModel();
$field = 'longitude,latitude';
$data = $m_location->findAllData($field, $where);
return $this->response(200, '', $data);
}
}
\ No newline at end of file
......@@ -12,7 +12,7 @@ use think\Model;
* Time : 14:26:58
* Intro:
*/
class ALocationListModel extends Model
class ALocationListModel extends BaseModel
{
protected $table = "a_location_list";
private $db_;
......@@ -45,4 +45,18 @@ class ALocationListModel extends Model
->order($order)
->find();
}
/**
* @param $field
* @param $where
* @param string $order
* @return false|\PDOStatement|string|\think\Collection
*/
public function findAllData($field, $where, $order = 'id asc')
{
return $this->db_->field($field)
->where($where)
->order($order)
->select();
}
}
\ No newline at end of file
......@@ -1008,6 +1008,7 @@ Route::group('broker', [
'saveSiteCity' => ['api_broker/Location/saveSiteCity', ['method' => 'POST|GET']], //保存默认城市选择
'addLocation' => ['api_broker/Location/addLocation', ['method' => 'POST|get']], //新增定位
'getLocationList' => ['api_broker/Location/getLocationList', ['method' => 'POST|get']], //定位多个坐标
'bargainMain' => ['api_broker/Bargain/bargainList', ['method' => 'POST|GET']],
'bargainMainV2' => ['api_broker/Bargain/bargainListV2', ['method' => 'POST|GET']],
'bargainListSearchBargainId' => ['api_broker/Bargain/bargainListSearchBargainId', ['method' => 'POST|GET']],
......
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