提交其他文件
This commit is contained in:
35
app/api/logic/StoreLogic.php
Normal file
35
app/api/logic/StoreLogic.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\logic;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\store\StoreUser;
|
||||
|
||||
class StoreLogic extends BaseLogic
|
||||
{
|
||||
public static function storeList($post){
|
||||
$s = "";
|
||||
if(isset($post['search'])){
|
||||
if($post['search'] != ""){
|
||||
$b = $post['search'];
|
||||
$s = "name like '%".$b."%'";
|
||||
}
|
||||
}
|
||||
$count = Store::where($s)->count();
|
||||
$lists = Store::where($s)
|
||||
->page($post['page'], $post['size'])
|
||||
->select()
|
||||
->toarray();
|
||||
foreach($lists as $key=>$value){
|
||||
$lists[$key]['distance'] = calculateDistanceKm($value['lat'],$value['lon'],$post['latitude'],$post['longitude']);
|
||||
}
|
||||
$data = [
|
||||
'list' => $lists,
|
||||
'page' => $post['page'],
|
||||
'size' => $post['size'],
|
||||
'count' => $count,
|
||||
'more' => is_more($count, $post['page'], $post['size'])
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user