From a78bb5d46c8e90f1306f89a144aeaf6ed6923cc7 Mon Sep 17 00:00:00 2001 From: wangxiaowei Date: Wed, 16 Oct 2024 15:12:40 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E5=86=99=E8=8E=B7=E5=8F=96=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=95=86=E5=AE=B6=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/LocalStoreLogic.php | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/app/api/logic/LocalStoreLogic.php b/app/api/logic/LocalStoreLogic.php index c72615eb..f3b24271 100644 --- a/app/api/logic/LocalStoreLogic.php +++ b/app/api/logic/LocalStoreLogic.php @@ -6,6 +6,7 @@ use app\common\basics\Logic; use app\common\model\LocalStore; use app\common\model\localstore\LocalGoodsStore; use app\common\model\localstore\LocalStoreBind; +use app\common\model\localstore\LocalStoreGoodsPic; use app\common\model\LocalStoreOrder; use app\common\model\LocalStorePostStation; use app\common\model\user\User; @@ -114,29 +115,36 @@ class LocalStoreLogic extends Logic // 城市搜索 if (isset($data['c_name']) && $data['c_name'] != "") { - $where[] = ['address', 'like', '%' . $data['c_name'] . '%']; + $where[] = ['ls.address', 'like', '%' . $data['c_name'] . '%']; } // 搜索商家名称 if (isset($data['keyword']) && $data['keyword'] != '') { - $where[] = ['shopName', 'like', '%' . $data['keyword'] . '%']; + $where[] = ['ls.shopName|lsg.title', 'like', '%' . $data['keyword'] . '%']; } // 数量统计 - $count = LocalStore::where(['is_delete' => 0, 'store_state' => 1]) + $count = LocalStore::alias('ls') + ->join('local_store_goods lsg', 'ls.lstore_id = lsg.lstore_id') + ->where(['ls.is_delete' => 0, 'ls.store_state' => 1]) ->where($where) - ->whereNotNull('shopLogo') + ->whereNotNull('ls.shopLogo') ->count(); // 列表 - $lists = LocalStore::where(['is_delete' => 0, 'store_state' => 1]) + $lists = LocalStore::alias('ls') + ->join('local_store_goods lsg', 'ls.lstore_id = lsg.lstore_id') + ->where(['ls.is_delete' => 0, 'ls.store_state' => 1]) ->where($where) - ->whereNotNull('shopLogo') - ->order('sort desc') + ->whereNotNull('ls.shopLogo') + ->order('lsg.id desc') ->page($data['page_no'], $data['page_size']) - ->select(); + ->field('ls.lstore_id as ls_id, ls.shopName, ls.longitude, ls.latitude, lsg.id, lsg.lstore_id, lsg.title, lsg.price') + ->select()->toArray(); foreach ($lists as $key => &$value) { + $pic = LocalStoreGoodsPic::where('lsg_id', $value['id'])->field('url')->find(); + $lists[$key]['url'] = UrlServer::getFileUrl($pic['url']); $lists[$key]['distance'] = round($this->distance($data['latitude'], $data['longitude'], $value['latitude'], $value['longitude']) / 1000, 2) . "公里"; $lists[$key]['store_nickname'] = $value["shopName"]; }