From efe6cc7e6db95e862560171c4887840335b9b116 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 3 Nov 2023 10:08:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BA=91=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/listener/ProductCreate.php | 63 ++++++++++++++-------------------- 1 file changed, 26 insertions(+), 37 deletions(-) diff --git a/app/listener/ProductCreate.php b/app/listener/ProductCreate.php index a18573ec..59644a15 100644 --- a/app/listener/ProductCreate.php +++ b/app/listener/ProductCreate.php @@ -1,5 +1,6 @@ where('type_code', Merchant::TypeCode['TypeCloudWarehouse'])->value('mer_type_id'); - $typePlatformId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypePlatform'])->value('mer_type_id'); - if ($merchant['type_id'] == $typePlatformId || $merchant['type_id'] == $typeCloudWarehouseId) { - return false; - } - - //查询市级供应链 - $mer = Db::name('merchant')->where('status', 1)->where('mer_state', 1)->where('category_id', $merchant['category_id'])->where('type_id',Merchant::TypePlatform)->value('mer_id'); - if($mer==null){ - return false; - } - $product_id=Db::name('store_product')->where('mer_id',$mer)->where('bar_code', $product['bar_code'])->value('product_id'); - if($product_id){ - return false; - } // 根据支持同步到云商的商户进行同步操作 $syncMerArray = Db::name('MerchantType')->where('is_sync_prod', 1)->column('mer_type_id'); if (!in_array($merchant['type_id'], $syncMerArray)) { return false; } - //市级云仓 - $cityMerchant = Db::name('merchant')->where('status', 1)->where('mer_state', 1)->where('category_id', $merchant['category_id'])->where('type_id', $typePlatformId)->find(); - if ($cityMerchant) { - $where = ['mer_id' => $cityMerchant['mer_id'], 'is_del' => 0]; - if ($product['bar_code'] != '' && in_array($product['product_type'], [0, 98]) && $product['spec_type'] == 0) { - $where['bar_code'] = $product['bar_code']; - } else { - $where['store_name'] = $product['store_name']; - } - $exist = Db::name('store_product')->where($where)->find(); - if (!$exist) { - $data['mer_id'] = $cityMerchant['mer_id']; - $data['status'] = $cityMerchant['is_audit'] ? 0 : 1; - $data['mer_status'] = ($cityMerchant['is_del'] || !$cityMerchant['mer_state'] || !$cityMerchant['status']) ? 0 : 1; - $data['rate'] = 3; - $typeSupplyChainId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypeSupplyChain'])->value('mer_type_id'); - $productType = $cityMerchant['type_id'] == $typeSupplyChainId ? 98 : 0; - $data['update_time'] = date('Y-m-d H:i:s'); - app()->make(ProductRepository::class)->create($data, $productType, $contentType); - } + $typeCloudWarehouseId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypeCloudWarehouse'])->value('mer_type_id'); + $typePlatformId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypePlatform'])->value('mer_type_id'); + if ($merchant['type_id'] == $typePlatformId || $merchant['type_id'] == $typeCloudWarehouseId) { + return false; } - } + //查询市级云仓 + $cityMerchant = Db::name('merchant')->where('status', 1)->where('mer_state', 1)->where('category_id', $merchant['category_id'])->where('type_id', Merchant::TypePlatform)->find(); + if ($cityMerchant == null) { + return false; + } + $product_id = Db::name('store_product')->where('mer_id', $cityMerchant['mer_id'])->where('bar_code', $product['bar_code'])->value('product_id'); + if ($product_id) { + return false; + } + + $data['mer_id'] = $cityMerchant['mer_id']; + $data['status'] = $cityMerchant['is_audit'] ? 0 : 1; + $data['mer_status'] = ($cityMerchant['is_del'] || !$cityMerchant['mer_state'] || !$cityMerchant['status']) ? 0 : 1; + $data['rate'] = 3; + // $typeSupplyChainId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypeSupplyChain'])->value('mer_type_id'); + // $productType = $cityMerchant['type_id'] == $typeSupplyChainId ? 98 : 0; + $productType =0; + $data['update_time'] = date('Y-m-d H:i:s'); + app()->make(ProductRepository::class)->create($data, $productType, $contentType); + } }