重写获取本地商家方法

This commit is contained in:
wangxiaowei 2024-10-16 14:06:14 +08:00
parent 3d3b0dfcad
commit 241dcf3138

@ -108,6 +108,58 @@ class LocalStoreLogic extends Logic
return $data;
}
public function getLocalLists($data)
{
// $s = $s1 = $keyword = $keyword1 = "";
$where = [];
if (isset($data['c_name']) && $data['c_name'] != "") {
$where[] = ['address', 'like', '%' . $data['c_name'] . '%'];
// $s1 = "address like '%" . $data['c_name'] . "%'";
// $s = "and address like '%" . $data['c_name'] . "%'";
}
// 搜索商家名称
if (isset($data['keyword']) && $data['keyword'] != '') {
$where[] = ['shopName', 'like', '%' . $data['keyword'] . '%'];
// $keyword1 = "shopName like '%" . $data['keyword'] . "%'";
// $keyword = "and shopName like '%" . $data['keyword'] . "%'";
}
$count = LocalStore::where([
'is_delete' => 0,
'store_state' => 1,
'shopLogo' => 'not null'
])->where($where)->count();
// $size = $data['page_size'];
// $page = ($data['page_no'] - 1) * $data['page_size'];
$lists = LocalStore::where(['is_delete' => 0, 'store_state' => 1, 'shopLogo' => 'not null'])
->where($where)
->order('sort desc')
->page($data['page_no'], $data['page_size'])
->select();
dump($lists);
die;
// $sql = "SELECT * FROM ls_local_store where is_delete = 0 and store_state = 1 and shopLogo is not null $s $keyword ORDER BY sort desc limit " . $page . "," . $size;
//
// $lists = Db::query($sql);
foreach ($lists as $key => &$value) {
$lists[$key]['distance'] = round($this->distance($data['latitude'], $data['longitude'], $value['latitude'], $value['longitude']) / 1000, 2) . "公里";
$lists[$key]['store_nickname'] = $value["shopName"];
}
$data = [
'list' => $lists,
'page' => $data['page_no'],
'size' => $data['page_size'],
'count' => $count,
'more' => is_more($count, $data['page_no'], $data['page_size'])
];
// var_dump($data);
return $data;
}
public function getStreetlList($data)
{
$model = new LocalStore;