From f685e9d77c47450107b4b46c189f07d867b0980d Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 2 Nov 2023 14:31:26 +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/admin/ProductLibrary.php | 3 +-- .../api/store/product/StoreMicro.php | 20 +++++++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/app/controller/admin/ProductLibrary.php b/app/controller/admin/ProductLibrary.php index 78f8ef16..491169ac 100644 --- a/app/controller/admin/ProductLibrary.php +++ b/app/controller/admin/ProductLibrary.php @@ -96,7 +96,6 @@ class ProductLibrary extends BaseController $result = $client->barcodeQuery() ->withCode($code) ->request(); - try { if ($result['code'] == 0) { $upload = UploadService::create(); @@ -106,7 +105,7 @@ class ProductLibrary extends BaseController $data['store_name'] = $param['goodsName']; $data['store_info'] = ''; $data['keyword'] = ''; - $data['bar_code'] = $param['code']; + $data['bar_code'] = $code; $data['is_used'] = 1; $data['status'] = 1; $data['cate_id'] = 0; diff --git a/app/controller/api/store/product/StoreMicro.php b/app/controller/api/store/product/StoreMicro.php index ff9a5975..4f2c4a78 100644 --- a/app/controller/api/store/product/StoreMicro.php +++ b/app/controller/api/store/product/StoreMicro.php @@ -12,7 +12,7 @@ class StoreMicro extends BaseController { function seach_bar_code($code='',$name=''){ $where = ['is_used' => 1, 'status' => 1, 'is_del' => 0]; - $field = 'id,store_name,bar_code,unit_name,price,cost,ot_price,stock,image'; + $field = 'id,store_name,bar_code,manu_address,price,stock,image,slider_image,spec,trademark,manu_name,manu_address,note'; if($code!=''){ $len=strlen($code); if ($len <13) { @@ -22,12 +22,20 @@ class StoreMicro extends BaseController return app('json')->fail('长度不正确'.$code); } } - $res=Db::name('product_library')->where('bar_code',$code)->where($where)->field($field)->find(); + $res=Db::name('product_library')->where('bar_code',$code)->where($where)->field($field) + ->withAttr('slider_image',function($value,$data){ + return $value?explode(',',$value):[]; + }) + ->find(); if($res==null){ $ProductLibrary = app()->make(ProductLibrary::class); try{ $ProductLibrary->caiji($code); - $res=Db::name('product_library')->where('bar_code',$code)->where($where)->field($field)->find(); + $res=Db::name('product_library')->where('bar_code',$code)->where($where)->field($field) + ->withAttr('slider_image',function($value,$data){ + return $value?explode(',',$value):[]; + }) + ->find(); }catch(Exception $e){ return app('json')->fail('编码:'.$code.'。'.$e->getMessage()); } @@ -37,7 +45,11 @@ class StoreMicro extends BaseController if($name==''){ return app('json')->fail('参数不能为空'); } - $find=Db::name('product_library')->where('store_name','like','%'.$name.'%')->where($where)->field($field)->select(); + $find=Db::name('product_library')->where('store_name','like','%'.$name.'%')->where($where)->field($field) + ->withAttr('slider_image',function($value,$data){ + return $value?explode(',',$value):[]; + }) + ->select(); } if (count($find)==0){ if($code!=''){