更新云商品导入
This commit is contained in:
parent
1b863887ea
commit
efe6cc7e6d
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace app\listener;
|
namespace app\listener;
|
||||||
@ -19,48 +20,36 @@ class ProductCreate
|
|||||||
if (empty($merchant)) {
|
if (empty($merchant)) {
|
||||||
return false;
|
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');
|
$syncMerArray = Db::name('MerchantType')->where('is_sync_prod', 1)->column('mer_type_id');
|
||||||
if (!in_array($merchant['type_id'], $syncMerArray)) {
|
if (!in_array($merchant['type_id'], $syncMerArray)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//市级云仓
|
$typeCloudWarehouseId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypeCloudWarehouse'])->value('mer_type_id');
|
||||||
$cityMerchant = Db::name('merchant')->where('status', 1)->where('mer_state', 1)->where('category_id', $merchant['category_id'])->where('type_id', $typePlatformId)->find();
|
$typePlatformId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypePlatform'])->value('mer_type_id');
|
||||||
if ($cityMerchant) {
|
if ($merchant['type_id'] == $typePlatformId || $merchant['type_id'] == $typeCloudWarehouseId) {
|
||||||
$where = ['mer_id' => $cityMerchant['mer_id'], 'is_del' => 0];
|
return false;
|
||||||
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) {
|
//查询市级云仓
|
||||||
|
$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['mer_id'] = $cityMerchant['mer_id'];
|
||||||
$data['status'] = $cityMerchant['is_audit'] ? 0 : 1;
|
$data['status'] = $cityMerchant['is_audit'] ? 0 : 1;
|
||||||
$data['mer_status'] = ($cityMerchant['is_del'] || !$cityMerchant['mer_state'] || !$cityMerchant['status']) ? 0 : 1;
|
$data['mer_status'] = ($cityMerchant['is_del'] || !$cityMerchant['mer_state'] || !$cityMerchant['status']) ? 0 : 1;
|
||||||
$data['rate'] = 3;
|
$data['rate'] = 3;
|
||||||
$typeSupplyChainId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypeSupplyChain'])->value('mer_type_id');
|
// $typeSupplyChainId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypeSupplyChain'])->value('mer_type_id');
|
||||||
$productType = $cityMerchant['type_id'] == $typeSupplyChainId ? 98 : 0;
|
// $productType = $cityMerchant['type_id'] == $typeSupplyChainId ? 98 : 0;
|
||||||
|
$productType =0;
|
||||||
$data['update_time'] = date('Y-m-d H:i:s');
|
$data['update_time'] = date('Y-m-d H:i:s');
|
||||||
app()->make(ProductRepository::class)->create($data, $productType, $contentType);
|
app()->make(ProductRepository::class)->create($data, $productType, $contentType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user