作者 何书鹏
1 个管道 的构建 通过 耗费 10 秒

附近工作由近及远

... ... @@ -193,9 +193,9 @@ class Index extends Api
$where .= "(".implode(' or ',$findinset)." or user_ids = '')";
}
// 附近
$distance = 0;
$juli = 0;
if($lng && $lat){
$distance = "ROUND(
$juli = "ROUND(
6378.138 * 2 * ASIN(
SQRT(
POW(
... ... @@ -223,8 +223,8 @@ class Index extends Api
$where .= "find_in_set({$type},type)";
}
$data = Job::where($where)
->field("*,if($distance > 1000,CONCAT(ROUND($distance/1000,1),'km'),CONCAT($distance,'m')) distance")
->order(['distance'=>'asc','weigh'=>'desc'])
->field("*,$juli juli,if($juli > 1000,CONCAT(ROUND($juli/1000,1),'km'),CONCAT($juli,'m')) distance")
->order(['juli'=>'asc','weigh'=>'desc'])
->paginate($page_num,false,['page'=>$page])
->each(function($v){
$v->visible(['id','cover','job_name','salary','people_num','factory_price_total','factory_price','subsidy_price'])->append(['distance']);
... ...