This commit is contained in:
mkm 2023-11-02 14:31:26 +08:00
parent 69c16ed3a2
commit f685e9d77c
2 changed files with 17 additions and 6 deletions

View File

@ -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;

View File

@ -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!=''){