From 3f9bee5592d4eef6ec2e448169530f4cc52ffe95 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Wed, 1 Nov 2023 19:14:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/store/product/StoreMicro.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/app/controller/api/store/product/StoreMicro.php b/app/controller/api/store/product/StoreMicro.php index cd463d89..d3748a30 100644 --- a/app/controller/api/store/product/StoreMicro.php +++ b/app/controller/api/store/product/StoreMicro.php @@ -14,8 +14,13 @@ class StoreMicro extends BaseController $where = ['is_used' => 1, 'status' => 1, 'is_del' => 0]; $field = 'id,store_name,bar_code,unit_name,price,cost,ot_price,stock,image'; if($code!=''){ - if (strlen($code) <13) { - return app('json')->success('条形码长度不正确'); + $len=strlen($code); + if ($len <13) { + if($len==12){ + $code='0'.$code; + }else{ + return app('json')->success('条形码长度不正确'); + } } $res=Db::name('product_library')->where('bar_code',$code)->where($where)->field($field)->find(); if($res==null){ @@ -70,8 +75,12 @@ class StoreMicro extends BaseController if ($mer_id == 0) { return app('json')->fail('商户不存在'); } - // $mer= Db::name('merchant')->where('mer_id', $mer_id)->where('status', 1)->find(); - + $mer= Db::name('merchant')->where('mer_id', $mer_id)->find(); + $category_name= Db::name('merchant_category')->where('merchant_category_id', $mer['category_id'])->value('category_name'); + $store_category_id= Db::name('store_category')->where(['cate_name'=>$category_name,'level'=>2,'mer_id'=>0])->value('store_category_id'); + if(!$store_category_id){ + return app('json')->fail('没有对应的分类,请联系工作人员添加'); + } $find=Db::name('product_library')->where('id',$id)->where($where)->find(); if ($find) { @@ -104,6 +113,7 @@ class StoreMicro extends BaseController $find['source_library_id'] = $find['id']; $find['spec_type'] = 0; $find['delivery_free'] = 0; + $find['cate_id'] = $store_category_id; unset($find['create_time']); } $a= app()->make( ProductRepository::class)->create($find,0,1);