From a1aead642600405d5c68fbb40ecd9bca7dff48e2 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sun, 5 Nov 2023 16:03:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/store/product/CloudWarehouse.php | 88 +++++++++++++------ route/api.php | 1 + 2 files changed, 64 insertions(+), 25 deletions(-) diff --git a/app/controller/api/store/product/CloudWarehouse.php b/app/controller/api/store/product/CloudWarehouse.php index 4e7263a3..dd0ce4e4 100644 --- a/app/controller/api/store/product/CloudWarehouse.php +++ b/app/controller/api/store/product/CloudWarehouse.php @@ -80,7 +80,7 @@ class CloudWarehouse extends BaseController // // $entryWhere['category_id'] = $params['category_id']; // // } // // $where['entry_mer_id'] = $this->merchantDao->search($entryWhere)->value('mer_id'); - + // $where['entry_mer_id'] = 0; // $where['keyword'] = $params['keyword']; // $where['mer_ids'] = $merchantIds; @@ -95,32 +95,70 @@ class CloudWarehouse extends BaseController * 云仓商品列表 * @return mixed */ - public function index($street_code,$page_num=1,$category_id=0){ - if($category_id==0){ + public function index($street_code, $page_num = 1, $category_id = 0) + { + if ($category_id == 0) { return app('json')->fail('分类id不能为0'); } - $cloud_product=Db::name('cloud_product')->where('street_code',$street_code)->where('category_id',$category_id)->where('status',1)->page($page_num)->column('product_id'); - if(!$cloud_product){ - return app('json')->success(['count'=>0,'list'=>[]]); + $cloud_product = Db::name('cloud_product')->where('street_code', $street_code)->where('category_id', $category_id)->where('status', 1)->page($page_num)->column('product_id'); + if (!$cloud_product) { + return app('json')->success(['count' => 0, 'list' => []]); } - $where=[ - 'is_show'=>1, - 'is_used'=>1, - 'status'=>1, - 'is_del'=>0, - 'mer_status'=>1, + $where = [ + 'is_show' => 1, + 'is_used' => 1, + 'status' => 1, + 'is_del' => 0, + 'mer_status' => 1, ]; - $count=Db::name('cloud_product')->where('street_code',$street_code)->where('status',1)->count(); - $select=Db::name('store_product')->whereIn('product_id',$cloud_product)->where($where) - ->withAttr('merchant',function($value,$data){ - return Db::name('merchant')->where('mer_id',$data['mer_id'])->field('mer_id,mer_name')->find(); - }) - ->withAttr('sku',function($value,$data){ - $find= Db::name('store_product_attr_value')->where('mer_id',$data['mer_id'])->where('product_id',$data['product_id'])->find(); - return[''=>$find]; - }) - // ->field('product_id,mer_id,store_name,bar_code,price,stock,product_type,image') - ->select(); - return app('json')->success(['count'=>$count,'list'=>$select]); + $count = Db::name('cloud_product')->where('street_code', $street_code)->where('status', 1)->count(); + $select = Db::name('store_product')->whereIn('product_id', $cloud_product)->where($where) + ->withAttr('merchant', function ($value, $data) { + return Db::name('merchant')->where('mer_id', $data['mer_id'])->field('mer_id,mer_name')->find(); + }) + ->withAttr('sku', function ($value, $data) { + $find = Db::name('store_product_attr_value')->where('mer_id', $data['mer_id'])->where('product_id', $data['product_id'])->find(); + return ['' => $find]; + }) + // ->field('product_id,mer_id,store_name,bar_code,price,stock,product_type,image') + ->select(); + return app('json')->success(['count' => $count, 'list' => $select]); } -} \ No newline at end of file + + /** + * 指定类型的云仓商品列表 + * @return mixed + */ + public function town() + { + // 除了市级供应链都可以查询 + $params = $this->request->params(['category_id', 'street_code', 'order', ['product_type', 0], 'keyword', 'page_num']); + $search = [ + 'street_id' => $params['street_code'], + 'type_id' => Merchant::TypeTownSupplyChain, + 'status' => 1, + 'is_del' => 0, + 'mer_state' => 1, + ]; + if (!empty($params['category_id'])) { + $search['category_id'] = $params['category_id']; + } + $merchantIds = $this->merchantDao->search($search)->column('mer_id'); + [$page, $limit] = $this->getPage(); + if (isset($params['page_num']) && $params['page_num'] != '') { + $page = $params['page_num']; + } + if (empty($merchantIds)) { + return app('json')->success(['count' => 0, 'list' => []]); + } + + $where['entry_mer_id'] = 0; + $where['keyword'] = $params['keyword']; + $where['mer_ids'] = $merchantIds; + $where['product_type'] = $params['product_type']; + $where['is_gift_bag'] = 0; + $where['order'] = $params['order'] ?: 'sort'; + $products = $this->spuRepository->getApiCloudSearch($where, $page, $limit, false); + return app('json')->success($products); + } +} diff --git a/route/api.php b/route/api.php index 264cfb1e..7d5ec25d 100644 --- a/route/api.php +++ b/route/api.php @@ -594,6 +594,7 @@ Route::group('api/', function () { Route::any('store/test', 'api.Test/test'); Route::get('subscribe', 'api.Common/subscribe'); Route::resource('store/product/cloudWarehouse', 'api.store.product.CloudWarehouse'); + Route::get('store/product/town_cloud', 'api.store.product.CloudWarehouse/town'); })->middleware(UserTokenMiddleware::class, false); //微信支付回调