From b18d1595a41d40df9a13cef0e76b9f2a56635476 Mon Sep 17 00:00:00 2001 From: xucong <850806214@qq.com> Date: Sat, 18 Apr 2026 11:13:26 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/ShopGoodsCategory.php | 13 ++++++++++- app/api/logic/ShopGoodsCategoryLogic.php | 29 ++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/app/api/controller/ShopGoodsCategory.php b/app/api/controller/ShopGoodsCategory.php index 424028e0..4df90ee2 100644 --- a/app/api/controller/ShopGoodsCategory.php +++ b/app/api/controller/ShopGoodsCategory.php @@ -26,7 +26,7 @@ use app\api\logic\ShopGoodsCategoryLogic; class ShopGoodsCategory extends Api { - public $like_not_need_login = ['getShopGoodsCategory']; + public $like_not_need_login = ['getShopGoodsCategory','getCityGoodsCategory']; public function getShopGoodsCategory() { @@ -42,4 +42,15 @@ class ShopGoodsCategory extends Api return JsonServer::error('请求类型错误'); } } + + public function getCityGoodsCategory() + { + if($this->request->isGet()) { + $city_id = $this->request->get('city_id', 0); + $data = ShopGoodsCategoryLogic::getCityGoodsCategory($city_id); + return JsonServer::success('获取店铺分类成功', $data); + }else{ + return JsonServer::error('请求类型错误'); + } + } } \ No newline at end of file diff --git a/app/api/logic/ShopGoodsCategoryLogic.php b/app/api/logic/ShopGoodsCategoryLogic.php index 7bb3f40b..0e24031e 100644 --- a/app/api/logic/ShopGoodsCategoryLogic.php +++ b/app/api/logic/ShopGoodsCategoryLogic.php @@ -2,6 +2,7 @@ namespace app\api\logic; use app\common\basics\Logic; +use app\common\model\shop\Shop; use app\common\model\shop\ShopGoodsCategory; class ShopGoodsCategoryLogic extends Logic @@ -25,4 +26,32 @@ class ShopGoodsCategoryLogic extends Logic return $data; } + + public static function getCityGoodsCategory($city_id) + { + $shop_msg = Shop::where("city_id",$city_id) + ->where("is_run",1) + ->where("is_freeze",0) + ->where("del",0) + ->find(); + $c = ""; + if($shop_msg == null){ + $shopId = 1; + }else{ + $shopId = $shop_msg['id']; + } + $where = [ + 'del' => 0, + 'shop_id' => $shopId, + 'is_show' => 1 + ]; + $order = [ + 'sort' => 'asc', + 'id' => 'desc' + ]; + $data = ShopGoodsCategory::field('id,name') + ->where($where)->order($order)->select()->toArray(); + + return $data; + } } \ No newline at end of file