diff --git a/app/listener/ProductCreate.php b/app/listener/ProductCreate.php index fa580678..e9229199 100644 --- a/app/listener/ProductCreate.php +++ b/app/listener/ProductCreate.php @@ -12,7 +12,7 @@ class ProductCreate public function handle($event) { - $merchant=Db::name('merchant')->where('mer_id',$event['product']['mer_id'])->find(); + $merchant=Db::name('merchant')->where('status',1)->where('mer_state',1)->where('mer_id',$event['product']['mer_id'])->find(); if ($merchant['type_id']==11){ $this->CloudMerchanSpu($merchant,$event); } @@ -20,9 +20,8 @@ class ProductCreate return false; } $product_find=Db::name('store_product')->where('product_id',$event['product']['product_id'])->where('mer_id',$event['product']['mer_id'])->find(); - //市级云仓 - $cityMerchantId = Db::name('merchant')->where('category_id',$merchant['category_id'])->where('type_id',13)->value('mer_id'); + $cityMerchantId = Db::name('merchant')->where('status',1)->where('mer_state',1)->where('category_id',$merchant['category_id'])->where('type_id',13)->value('mer_id'); if ($cityMerchantId) { $is_product=0; if ($product_find['bar_code']!='' &&in_array($product_find['product_type'],[0,98]) &&$product_find['spec_type']==0){ @@ -42,24 +41,26 @@ class ProductCreate } //镇街云仓 $is_product=0; - if ($merchant['type_id']==11){ - $townMerchantId = Db::name('merchant')->where('category_id',$merchant['category_id'])->where('type_id',11)->value('mer_id'); - if ($product_find['bar_code']!='' &&in_array($product_find['product_type'],[0,98]) &&$product_find['spec_type']==0){ - $find=Db::name('store_product')->where('bar_code',$product_find['bar_code'])->where('mer_id',$townMerchantId)->find(); - if (!$find){ - $is_product=1; + if ($merchant['type_id']==10){ + $townMerchantId = Db::name('merchant')->where('status',1)->where('mer_state',1)->where('category_id',$merchant['category_id'])->where('type_id',11)->value('mer_id'); + if ($townMerchantId){ + if ($product_find['bar_code']!='' &&in_array($product_find['product_type'],[0,98]) &&$product_find['spec_type']==0){ + $find=Db::name('store_product')->where('bar_code',$product_find['bar_code'])->where('mer_id',$townMerchantId)->find(); + if (!$find){ + $is_product=1; + } + }else{ + $find=Db::name('store_product')->where('store_name',$product_find['store_name'])->where('mer_id',$townMerchantId)->find(); + if (!$find){ + $is_product=1; + } } - }else{ - $find=Db::name('store_product')->where('store_name',$product_find['store_name'])->where('mer_id',$townMerchantId)->find(); - if (!$find){ - $is_product=1; + if ($is_product==1){ + $this->AddProduct($townMerchantId,$product_find,$event); } } - if ($is_product==1){ - $this->AddProduct($townMerchantId,$product_find,$event); - } + } - return false; } public function CloudMerchanSpu($data,$event){