From 04c91314ee52637fd17bf1c7c6ac92bf43a3cfc2 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 4 Nov 2023 11:43:39 +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 --- app/controller/api/Auth.php | 4 ---- .../api/store/product/CloudWarehouse.php | 17 +++++++++++------ app/controller/api/store/product/StoreMicro.php | 4 +++- app/listener/ProductCreate.php | 4 +++- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/app/controller/api/Auth.php b/app/controller/api/Auth.php index 52ddbda4..cf1b61bb 100644 --- a/app/controller/api/Auth.php +++ b/app/controller/api/Auth.php @@ -188,10 +188,6 @@ class Auth extends BaseController public function test() { - $merchant = Db::name('merchant')->where('status', 1)->where('is_del', 0)->where('mer_id',56)->find(); - $cityMerchant = Db::name('merchant')->where('status', 1)->where('mer_state', 1)->where('category_id', $merchant['category_id'])->where('type_id', Merchant::TypeSupplyChain)->find(); - $product_id = Db::name('store_product')->where('mer_id', $cityMerchant['mer_id'])->where('bar_code', '6926265365132')->value('product_id'); - $type = $this->request->param('type'); $res = []; switch ($type) { diff --git a/app/controller/api/store/product/CloudWarehouse.php b/app/controller/api/store/product/CloudWarehouse.php index 041b6b42..6353ab08 100644 --- a/app/controller/api/store/product/CloudWarehouse.php +++ b/app/controller/api/store/product/CloudWarehouse.php @@ -95,8 +95,11 @@ class CloudWarehouse extends BaseController * 云仓商品列表 * @return mixed */ - public function index($street_code,$page_num=1){ - $cloud_product=Db::name('cloud_product')->where('street_code',$street_code)->where('status',1)->page($page_num)->select(); + 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'=>[]]); } @@ -108,10 +111,12 @@ class CloudWarehouse extends BaseController '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)->select(); - if(!$select){ - $count=0; - } + $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(); + }) + ->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 diff --git a/app/controller/api/store/product/StoreMicro.php b/app/controller/api/store/product/StoreMicro.php index 07b28748..bba75b8c 100644 --- a/app/controller/api/store/product/StoreMicro.php +++ b/app/controller/api/store/product/StoreMicro.php @@ -72,6 +72,7 @@ class StoreMicro extends BaseController $id = $this->request->param('id', 0); $price = $this->request->param('price', 0); $stock = $this->request->param('stock', 0); + $store_name = $this->request->param('store_name', ''); $user = $this->request->userInfo(); $where = ['is_used' => 1, 'status' => 1, 'is_del' => 0]; try { @@ -90,7 +91,7 @@ class StoreMicro extends BaseController $exist = Db::name('store_product')->where('source_library_id', $id)->where('mer_id', $mer_id)->find(); if ($exist) { - return app('json')->fail('已经导入过该商品了'); + // return app('json')->fail('已经导入过该商品了'); } $find['attrValue']=[ ['image'=>$find['image'],'price'=>$price,'cost'=>$find['cost'],'ot_price'=>$find['ot_price'], @@ -101,6 +102,7 @@ class StoreMicro extends BaseController }else{ $product_type=0; } + $find['store_name'] =$store_name??$find['store_name']; $find['content'] =['image'=>explode(',',$find['images'])]; $find['slider_image'] =explode(',',$find['slider_image']); $find['is_show'] = 1; diff --git a/app/listener/ProductCreate.php b/app/listener/ProductCreate.php index 67808070..2a775a70 100644 --- a/app/listener/ProductCreate.php +++ b/app/listener/ProductCreate.php @@ -45,7 +45,7 @@ class ProductCreate } //查询市级供应链商品 $product_id = Db::name('store_product')->where('mer_id', $cityMerchant['mer_id'])->where('bar_code', $product['bar_code'])->value('product_id'); - if ($product_id) { + if (!$product_id) { return false; } //添加到云仓 @@ -54,6 +54,8 @@ class ProductCreate 'mer_id'=>$merchant['mer_id'], 'source_mer_id'=>$cityMerchant['mer_id'], 'street_code'=>$merchant['street_id'], + 'type_id'=>$merchant['type_id'], + 'category_id'=>$merchant['category_id'], 'weight'=>1, 'status'=>1, 'create_time'=>date('Y-m-d H:i:s'),