diff --git a/app/api/logic/LocalStoreLogic.php b/app/api/logic/LocalStoreLogic.php index d57ffe27..2b46300f 100644 --- a/app/api/logic/LocalStoreLogic.php +++ b/app/api/logic/LocalStoreLogic.php @@ -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;