Commit dfd4efc6 authored by clone's avatar clone

1

parent 18d19cbe
...@@ -31,24 +31,24 @@ class Location extends Basic ...@@ -31,24 +31,24 @@ class Location extends Basic
public function saveSiteCity() public function saveSiteCity()
{ {
$params = $this->params; $params = $this->params;
/* $params = array( /* $params = array(
"agent_id" => 1, "agent_id" => 1,
"city" => "上海市" "city" => "上海市"
);*/ );*/
/* $checkResult = $this->validate($params, "LocationValidate.saveSiteCityVerify"); /* $checkResult = $this->validate($params, "LocationValidate.saveSiteCityVerify");
if (true !== $checkResult) { if (true !== $checkResult) {
return $this->response("101", $checkResult); return $this->response("101", $checkResult);
} }
$city = "上海市"; $city = "上海市";
$agent_id = $params["agent_id"]; $agent_id = $params["agent_id"];
if ($params["city"] == "杭州市" || $params["city"] == "杭州") { if ($params["city"] == "杭州市" || $params["city"] == "杭州") {
$city = "杭州市"; $city = "杭州市";
} }
if ($this->redis_) { if ($this->redis_) {
$this->redis_->set(self::CITY_AGENTS . $agent_id, $city); $this->redis_->set(self::CITY_AGENTS . $agent_id, $city);
} else { } else {
return $this->response("101", "redis service not found"); return $this->response("101", "redis service not found");
}*/ }*/
return $this->response("200", "success", []); return $this->response("200", "success", []);
...@@ -61,7 +61,7 @@ class Location extends Basic ...@@ -61,7 +61,7 @@ class Location extends Basic
*/ */
public function addLocation() public function addLocation()
{ {
$code = 101; $code = 101;
$params = &$this->params; $params = &$this->params;
if (!isset($params['longitude']) || !isset($params['latitude']) || if (!isset($params['longitude']) || !isset($params['latitude']) ||
!isset($params['source']) !isset($params['source'])
...@@ -73,14 +73,15 @@ class Location extends Basic ...@@ -73,14 +73,15 @@ class Location extends Basic
return $this->response($code, '账号异常'); return $this->response($code, '账号异常');
} }
$m_location = new ALocationListModel(); $m_location = new ALocationListModel();
$position_service = new PositionService(); $position_service = new PositionService();
$s_redis = new RedisCacheService(); $s_redis = new RedisCacheService();
$where['agent_id'] = $params['agent_id']; $where['agent_id'] = $params['agent_id'];
$data = $m_location->findData('longitude,latitude', $where, 'id desc'); $where['location_date'] = date("Y-m-d", time());
$data = $m_location->findData('longitude,latitude', $where, 'id desc');
if ($params['longitude'].$params['latitude'] == $data['longitude'].$data['latitude']) { if ($params['longitude'] . $params['latitude'] == $data['longitude'] . $data['latitude']) {
return $this->response(101, '经纬度重复'); return $this->response(101, '经纬度重复');
} }
...@@ -94,24 +95,25 @@ class Location extends Basic ...@@ -94,24 +95,25 @@ class Location extends Basic
$agent_data = $s_redis->getRedisCache(2, $params['agent_id']); $agent_data = $s_redis->getRedisCache(2, $params['agent_id']);
if (empty($params['source'])) { if (empty($params['source'])) {
$save_data["source"] = 0; $save_data["source"] = 0;
$save_data["source_id"] = 0; $save_data["source_id"] = 0;
} else { } else {
$save_data["source"] = $params['source']; $save_data["source"] = $params['source'];
$save_data["source_id"] = $params['source_id']; $save_data["source_id"] = $params['source_id'];
} }
$save_data["agent_id"] = $params['agent_id']; $save_data["agent_id"] = $params['agent_id'];
$save_data["store_id"] = $agent_data['store_id']; $save_data["store_id"] = $agent_data['store_id'];
$save_data["district_id"] = $agent_data['district_id']; $save_data["district_id"] = $agent_data['district_id'];
$save_data["location_time"] = date('Y-m-d H:i:s'); $save_data["location_time"] = date('Y-m-d H:i:s');
$save_data["longitude"] = $params['longitude']; $save_data["location_date"] = date('Y-m-d');
$save_data["latitude"] = $params['latitude']; $save_data["longitude"] = $params['longitude'];
$num = $m_location->insertData($data); $save_data["latitude"] = $params['latitude'];
$num = $m_location->insertData($data);
if ($num > 0) { if ($num > 0) {
$code = 200; $code = 200;
$msg = '操作完成'; $msg = '操作完成';
} else { } else {
$msg = '插入定位数据失败'; $msg = '插入定位数据失败';
} }
......
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