作者 macbook
1 个管道 的构建 通过 耗费 11 秒

附近工作

... ... @@ -195,27 +195,25 @@ class Index extends Api
// 附近
$distance = 0;
if($lng && $lat){
$distance = "ROUND(
6378.138 * 2 * ASIN(
SQRT(
POW(
SIN(
(
{$lat} * PI() / 180 - lat * PI() / 180
) / 2
),
2
) + COS({$lat} * PI() / 180) * COS(lat * PI() / 180) * POW(
SIN(
(
{$lng} * PI() / 180 - lng * PI() / 180
) / 2
),
2
)
$distance = "6378.138 * 2 * ASIN(
SQRT(
POW(
SIN(
(
{$lat} * PI() / 180 - lat * PI() / 180
) / 2
),
2
) + COS({$lat} * PI() / 180) * COS(lat * PI() / 180) * POW(
SIN(
(
{$lng} * PI() / 180 - lng * PI() / 180
) / 2
),
2
)
) * 1000
)";
)
) * 1000";
}
// 职位类型
if($type){
... ... @@ -223,7 +221,7 @@ class Index extends Api
$where .= "find_in_set({$type},type)";
}
$data = Job::where($where)
->field("*,{$distance} distance")
->field("*,if($distance > 1000,CONCAT(ROUND($distance/1000,1),'千'),$distance) distance")
->order(['distance'=>'asc','weigh'=>'desc'])
->paginate($page_num,false,['page'=>$page])
->each(function($v){
... ... @@ -304,7 +302,7 @@ class Index extends Api
$where .= $where ? ' and ' : '';
$where .= "(".implode(' or ',$findinset)." or user_ids = '')";
}
$data = Job::alias('j')
->join('job_collect jc','jc.job_id = j.id and user_id = '.$this->auth->id)
->where($where)
... ...