Commit 8059ad50 by 杨树贤

导出数据

parent 7efbfafc
...@@ -453,16 +453,19 @@ class SupplierApiController extends Controller ...@@ -453,16 +453,19 @@ class SupplierApiController extends Controller
$this->response(0, '属于代购供应商,直接发送同步'); $this->response(0, '属于代购供应商,直接发送同步');
} }
//去调取天眼查数据,有数据的话,更新 //去调取天眼查数据,有数据的话,更新
$regionType = $supplier['region'] == 2 ? 1 : 2; $companyInfo = (new CompanyService())->getCompanyInfo($supplier['supplier_name'], '');
$companyInfo = (new CompanyService())->getCompanyInfo($supplier['supplier_name'], '', $regionType);
//先判断是否是标准添加,如果标准添加,国内地区,但是没有税号的,不允许同步 //先判断是否是标准添加,如果标准添加,国内地区,但是没有税号的,不允许同步
if ($supplier['is_standard_add'] == 1 && $supplier['region'] == 2 && !$supplier['tax_number']) { if ($supplier['is_standard_add'] == 1 && $supplier['region'] == 2 && !$supplier['tax_number'] && $companyInfo) {
$this->response(-1, '该供应商属于国内,但是没有税号,不允许同步'); $taxNumber = $companyInfo['tax_number'];
SupplierChannelModel::where('supplier_id', $supplierId)->update([
'tax_number' => $taxNumber,
]);
// $this->response(-1, '该供应商属于国内,但是没有税号,不允许同步');
} }
if ($supplier['is_standard_add'] == 1 && $supplier['region'] != 2) { if ($supplier['is_standard_add'] == 1 && $supplier['region'] != 2) {
if (empty($companyInfo)) { // if (empty($companyInfo)) {
$this->response(-1, '该供应商属于海外,但是无法查询公司信息,不允许同步'); // $this->response(-1, '该供应商属于海外,但是无法查询公司信息,不允许同步');
} // }
} }
$service = new SyncSupplierService(); $service = new SyncSupplierService();
$service->syncSupplierToUnited($supplierId); $service->syncSupplierToUnited($supplierId);
......
...@@ -472,7 +472,8 @@ class DataService ...@@ -472,7 +472,8 @@ class DataService
'supplier_name', 'supplier_name',
'channel_uid', 'channel_uid',
'create_time', 'create_time',
])->where('is_type', 0) ])->where('is_type', 0)->where('create_time', '>', 1655778780)
->where('update_time', '>', 1655778780)->where('group_code', '!=', '')
->whereRaw('supplier_name NOT LIKE "%-1"')->get(); ->whereRaw('supplier_name NOT LIKE "%-1"')->get();
$excelData = []; $excelData = [];
$header = [ $header = [
...@@ -522,7 +523,8 @@ class DataService ...@@ -522,7 +523,8 @@ class DataService
public function exportSupplierJsonForUnited() public function exportSupplierJsonForUnited()
{ {
$suppliers = SupplierChannelModel::where('is_type', 0) $suppliers = SupplierChannelModel::where('is_type', 0)
->pluck('supplier_group', 'supplier_id')->toArray(); ->pluck('supplier_group', 'supplier_id')->where('create_time', '>', 1655778780)
->where('update_time', '>', 1655778780)->where('group_code', '!=', '')->toArray();
$exportJson = []; $exportJson = [];
$items = array_map(function ($value) { $items = array_map(function ($value) {
$value = array_get(config('fixed.SupplierGroup'), $value); $value = array_get(config('fixed.SupplierGroup'), $value);
......
...@@ -60,5 +60,5 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function () ...@@ -60,5 +60,5 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
}); });
Route::match(['get', 'post'], '/test', function () { Route::match(['get', 'post'], '/test', function () {
(new \App\Http\Services\DataService())->checkCompanyName(); (new \App\Http\Services\DataService())->exportSupplierForUnionData();
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment