更新云商品导入

This commit is contained in:
mkm 2023-11-03 10:08:21 +08:00
parent 1b863887ea
commit efe6cc7e6d

View File

@ -1,5 +1,6 @@
<?php
declare (strict_types=1);
declare(strict_types=1);
namespace app\listener;
@ -19,48 +20,36 @@ class ProductCreate
if (empty($merchant)) {
return false;
}
$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;
}
//查询市级供应链
$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);
}
}