Commit 000ea922 authored by hujun's avatar hujun

定位

parent 30fdc81d
...@@ -360,11 +360,11 @@ class AppointmentTime extends Basic ...@@ -360,11 +360,11 @@ class AppointmentTime extends Basic
$field = 'id,operation_id,house_id,message,type'; $field = 'id,operation_id,house_id,message,type';
$id = $m_push->getListByWhere($field, $where, 1, 1); $id = $m_push->getListByWhere($field, $where, 1, 1);
if (empty($id[0]['id'])) { if (!empty($id[0]['id'])) {
$data['is_alert'] = 0; // $data['is_alert'] = 0;
$data['string_1'] = ''; // $data['string_1'] = '';
$data['string_2'] = ''; // $data['string_2'] = '';
} else { // } else {
$data['name'] = $id[0]['message']; $data['name'] = $id[0]['message'];
$data['is_alert'] = 1; $data['is_alert'] = 1;
$data['type'] = $id[0]['type']; $data['type'] = $id[0]['type'];
......
...@@ -195,7 +195,8 @@ class GeTuiUtils { ...@@ -195,7 +195,8 @@ class GeTuiUtils {
'id' => $user_id, 'id' => $user_id,
'house_id' => $house_id, 'house_id' => $house_id,
'order_id' => $order_id, 'order_id' => $order_id,
'imageUrl' => $home_url .'notice_android_logo.png')); 'imageUrl' => $home_url .'notice_android_logo.png',
'agent_id'=> $id));
return $this->push_message_for_one($data); return $this->push_message_for_one($data);
} }
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace app\api_broker\controller; namespace app\api_broker\controller;
use app\api_broker\extend\Basic; use app\api_broker\extend\Basic;
use app\api_broker\service\LocationService;
use app\api_broker\service\RedisCacheService; use app\api_broker\service\RedisCacheService;
use app\extra\RedisExt; use app\extra\RedisExt;
use app\index\service\PositionService; use app\index\service\PositionService;
...@@ -73,49 +74,13 @@ class Location extends Basic ...@@ -73,49 +74,13 @@ class Location extends Basic
return $this->response($code, '账号异常'); return $this->response($code, '账号异常');
} }
$m_location = new ALocationListModel(); $s_location = new LocationService();
$position_service = new PositionService(); $result = $s_location->add($params['agent_id'], $params['longitude'], $params['latitude']);
$s_redis = new RedisCacheService();
$where['agent_id'] = $params['agent_id']; if ($result['status'] != 'fail') {
$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']) {
return $this->response(101, '经纬度重复');
}
if (!empty($data)) {
$is_ = $position_service->checkDistance($params['latitude'], $params['longitude'], $data['latitude'], $data['longitude'], 500);
if ($is_) {
return $this->response(200, '距离没有超过500米');
}
}
$agent_data = $s_redis->getRedisCache(2, $params['agent_id']);
if (empty($params['source'])) {
$save_data["source"] = 0;
$save_data["source_id"] = 0;
} else {
$save_data["source"] = $params['source'];
$save_data["source_id"] = $params['source_id'];
}
$save_data["agent_id"] = $params['agent_id'];
$save_data["store_id"] = $agent_data['store_id'];
$save_data["district_id"] = $agent_data['district_id'];
$save_data["location_time"] = date('Y-m-d H:i:s');
$save_data["location_date"] = date('Y-m-d');
$save_data["longitude"] = $params['longitude'];
$save_data["latitude"] = $params['latitude'];
$num = $m_location->insertData($save_data);
if ($num > 0) {
$code = 200; $code = 200;
$msg = '操作完成';
} else {
$msg = '插入定位数据失败';
} }
$msg = $result['msg'];
return $this->response($code, $msg); return $this->response($code, $msg);
} }
} }
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: 43897
* Date: 2019/9/19
* Time: 10:56
*/
namespace app\api_broker\service;
use app\index\service\PositionService;
use app\model\ALocationListModel;
class LocationService
{
/**
* 新增定位
*
* @param $agent_id
* @param $longitude
* @param $latitude
* @param int $source
* @param int $source_id
* @return mixed
*/
public function add($agent_id, $longitude, $latitude, $source = 0, $source_id = 0)
{
$result['status'] = 'fail';
$m_location = new ALocationListModel();
$position_service = new PositionService();
$s_redis = new RedisCacheService();
$where['agent_id'] = $agent_id;
$where['location_date'] = date("Y-m-d", time());
$data = $m_location->findData('longitude,latitude', $where, 'id desc');
if ($longitude . $latitude == $data['longitude'] . $data['latitude']) {
$result['msg'] = '经纬度重复';
}
if (!empty($data)) {
$distance = 500;
$is_ = $position_service->checkDistance($latitude, $longitude, $data['latitude'], $data['longitude'], $distance);
if ($is_) {
$result['msg'] = '距离没有超过' . $distance . '米';
}
}
$agent_data = $s_redis->getRedisCache(2, $agent_id);
if ($source) {
$save_data["source"] = 0;
$save_data["source_id"] = 0;
} else {
$save_data["source"] = $source;
$save_data["source_id"] = $source_id;
}
$save_data["agent_id"] = $agent_id;
$save_data["store_id"] = $agent_data['store_id'];
$save_data["district_id"] = $agent_data['district_id'];
$save_data["location_time"] = date('Y-m-d H:i:s');
$save_data["location_date"] = date('Y-m-d');
$save_data["longitude"] = $longitude;
$save_data["latitude"] = $latitude;
$num = $m_location->insertData($save_data);
if ($num > 0) {
$result['status'] = 'successful';
$result['msg'] = '操作完成';
} else {
$result['msg'] = '插入定位数据失败';
}
return $result;
}
}
\ 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