|
|
@ -28,14 +28,14 @@ class AgentProductController extends Controller |
|
|
$lat = $formData['lat'] ?? 0; |
|
|
$lat = $formData['lat'] ?? 0; |
|
|
$lng = $formData['lng'] ?? 0; |
|
|
$lng = $formData['lng'] ?? 0; |
|
|
|
|
|
|
|
|
$list = AgentProductView::list($this->agent_id); |
|
|
|
|
|
|
|
|
$list = AgentProductView::list($this->agent_id)->addSelect('latitude', 'logitude', 'address'); |
|
|
if ($category_id) { |
|
|
if ($category_id) { |
|
|
$list = $list->whereIn('category_id', [$category_id, ...$this->get_category_child_ids($category_id)]); |
|
|
$list = $list->whereIn('category_id', [$category_id, ...$this->get_category_child_ids($category_id)]); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 距离排序,TODO 优化
|
|
|
// 距离排序,TODO 优化
|
|
|
if ($type == 4) { |
|
|
if ($type == 4) { |
|
|
$list = $list->addSelect('latitude', 'logitude', 'address', DB::raw(<<<SQL |
|
|
|
|
|
|
|
|
$list = $list->addSelect(DB::raw(<<<SQL |
|
|
round( |
|
|
round( |
|
|
(((6371.393 * 2) * asin( |
|
|
(((6371.393 * 2) * asin( |
|
|
sqrt(( |
|
|
sqrt(( |
|
|
|