GreenOperate.php 826 B

1234567891011121314151617
  1. <?php
  2. namespace app\green\model;
  3. use think\Db;
  4. use think\Model;
  5. class GreenOperate extends Model {
  6. //用户
  7. public function user(){
  8. return $this->hasOne('app\common\model\SystemUser','id','uid');
  9. }
  10. //查找最近运营商
  11. public function selectAll($param){
  12. return $info = Db::query('select * from '.config('database.prefix').'green_operate where latitude > '.$param['latitude'].'-1 and latitude < '.$param['latitude'].'+1 and longitude > '.$param['longitude'].'-1 and longitude < '.$param['longitude'].'+1 order by ACOS(SIN(('.$param['latitude'].' * 3.1415) / 180 ) *SIN((latitude * 3.1415) / 180 ) +COS(('.$param['latitude'].' * 3.1415) / 180 ) * COS((latitude * 3.1415) / 180 ) *COS(('.$param['longitude'].'* 3.1415) / 180 - (longitude * 3.1415) / 180 ) ) * 6380 asc limit 1');
  13. }
  14. }