Commit edad517f by 杨树贤

修改限制

parent 6a8a14a7
...@@ -7,6 +7,7 @@ use App\Http\Services\AdminUserService; ...@@ -7,6 +7,7 @@ use App\Http\Services\AdminUserService;
use App\Http\Services\CompanyService; use App\Http\Services\CompanyService;
use App\Model\BrandModel; use App\Model\BrandModel;
use App\Model\StandardBrandModel; use App\Model\StandardBrandModel;
use App\Model\SupplierChannelModel;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
...@@ -73,11 +74,17 @@ class CommonApiController extends Controller ...@@ -73,11 +74,17 @@ class CommonApiController extends Controller
$supplierName = $request->get('supplier_name'); $supplierName = $request->get('supplier_name');
$taxNumber = $request->get('tax_number'); $taxNumber = $request->get('tax_number');
$region = $request->get('region'); $region = $request->get('region');
$regionType = $region == 2 ? 1 : 2; $company = [];
$company = (new CompanyService())->getCompanyInfo($supplierName, $taxNumber, $regionType); if (in_array($region, config('field.NeedCheckCompanyRegion'))) {
if (!$company) { $regionType = $region == SupplierChannelModel::REGION_CN ? 1 : 2;
$this->response(-1, '获取不到公司'); $company = (new CompanyService())->getCompanyInfo($supplierName, $taxNumber, $regionType);
if (!$company) {
$this->response(-1, '获取不到公司');
}
}else{
$this->response(-3, '供应商跳过天眼查校验');
} }
$this->response(0, 'ok', $company); $this->response(0, 'ok', $company);
} }
......
...@@ -295,7 +295,7 @@ class SupplierApiController extends Controller ...@@ -295,7 +295,7 @@ class SupplierApiController extends Controller
//如果是编辑操作,则要忽略非当前 //如果是编辑操作,则要忽略非当前
if ($supplierId) { if ($supplierId) {
if (in_array($supplierId, [195, 12263])) { if (in_array($supplierId, config('field.NeedSkipSupplierNameCheckIds'))) {
$this->response(0, '供应商名称合理'); $this->response(0, '供应商名称合理');
} }
$originSupplierName = $model->where('supplier_id', $supplierId)->value('supplier_name'); $originSupplierName = $model->where('supplier_id', $supplierId)->value('supplier_name');
...@@ -312,20 +312,21 @@ class SupplierApiController extends Controller ...@@ -312,20 +312,21 @@ class SupplierApiController extends Controller
->value('supplier_name'); ->value('supplier_name');
if ($existedSupplierName) { if ($existedSupplierName) {
$this->response(-1, '供应商已存在,请重新输入或者咨询审批人'); $this->response(-1, '供应商已存在,请重新输入或者咨询审批人');
} else {
// $supplierName = $model->where('supplier_name', 'like',
// "%$supplierName%")->limit(1)->value('supplier_name');
// if (!empty($supplierName)) {
// $this->response(-2, '存在类似的供应商名称', $supplierName);
// }
} }
} }
$regionType = $region == 2 ? 1 : 2; $company = [];
//还要去请求天眼查获取资料 //判断用户选的地区是不是需要校验的,不需要直接返回即可
$company = (new CompanyService())->getCompanyInfo($supplierName, $taxNumber, $regionType); if (in_array($region, config('field.NeedCheckCompanyRegion'))) {
if (!$company) { $regionType = $region == SupplierChannelModel::REGION_CN ? 1 : 2;
$this->response(-2, '公司未进行工商注册,请修改后重新提交'); //还要去请求天眼查获取资料
$company = (new CompanyService())->getCompanyInfo($supplierName, $taxNumber, $regionType);
if (!$company) {
$this->response(-2, '公司未进行工商注册,请修改后重新提交');
}
} else {
$this->response(-3, '供应商跳过天眼查校验');
} }
$this->response(0, '供应商名称合理', $company); $this->response(0, '供应商名称合理', $company);
} }
...@@ -446,7 +447,7 @@ class SupplierApiController extends Controller ...@@ -446,7 +447,7 @@ class SupplierApiController extends Controller
$supplierId = $request->get('supplier_id'); $supplierId = $request->get('supplier_id');
$supplier = SupplierChannelModel::where('supplier_id', $supplierId)->first()->toArray(); $supplier = SupplierChannelModel::where('supplier_id', $supplierId)->first()->toArray();
if (in_array($supplier['supplier_name'],config('field.SkipChangeSupplierTypeNames'))) { if (in_array($supplier['supplier_name'], config('field.SkipChangeSupplierTypeNames'))) {
$service = new SyncSupplierService(); $service = new SyncSupplierService();
$service->syncSupplierToUnited($supplierId); $service->syncSupplierToUnited($supplierId);
...@@ -455,14 +456,14 @@ class SupplierApiController extends Controller ...@@ -455,14 +456,14 @@ class SupplierApiController extends Controller
//去调取天眼查数据,有数据的话,更新 //去调取天眼查数据,有数据的话,更新
$companyInfo = (new CompanyService())->getCompanyInfo($supplier['supplier_name'], ''); $companyInfo = (new CompanyService())->getCompanyInfo($supplier['supplier_name'], '');
//先判断是否是标准添加,如果标准添加,国内地区,但是没有税号的,不允许同步 //先判断是否是标准添加,如果标准添加,国内地区,但是没有税号的,不允许同步
if ($supplier['is_standard_add'] == 1 && $supplier['region'] == 2 && !$supplier['tax_number'] && $companyInfo) { if ($supplier['is_standard_add'] == 1 && $supplier['region'] == SupplierChannelModel::REGION_CN && !$supplier['tax_number'] && $companyInfo) {
$taxNumber = $companyInfo['tax_number']; $taxNumber = $companyInfo['tax_number'];
SupplierChannelModel::where('supplier_id', $supplierId)->update([ SupplierChannelModel::where('supplier_id', $supplierId)->update([
'tax_number' => $taxNumber, 'tax_number' => $taxNumber,
]); ]);
// $this->response(-1, '该供应商属于国内,但是没有税号,不允许同步'); // $this->response(-1, '该供应商属于国内,但是没有税号,不允许同步');
} }
if ($supplier['is_standard_add'] == 1 && $supplier['region'] != 2) { if ($supplier['is_standard_add'] == 1 && $supplier['region'] != SupplierChannelModel::REGION_CN) {
// if (empty($companyInfo)) { // if (empty($companyInfo)) {
// $this->response(-1, '该供应商属于海外,但是无法查询公司信息,不允许同步'); // $this->response(-1, '该供应商属于海外,但是无法查询公司信息,不允许同步');
// } // }
......
...@@ -82,7 +82,7 @@ class SupplierAuditService ...@@ -82,7 +82,7 @@ class SupplierAuditService
if ($status == SupplierChannelModel::STATUS_PASSED) { if ($status == SupplierChannelModel::STATUS_PASSED) {
if (!checkPerm('IgnoreCompanyCheck')) { if (!checkPerm('IgnoreCompanyCheck')) {
//判断有公司信息才允许同步给一体化 //判断有公司信息才允许同步给一体化
$regionType = $supplier['region'] == 2 ? 1 : 2; $regionType = $supplier['region'] == SupplierChannelModel::REGION_CN ? 1 : 2;
if ($regionType == 2) { if ($regionType == 2) {
(new SyncSupplierService())->syncSupplierToUnited($supplierId); (new SyncSupplierService())->syncSupplierToUnited($supplierId);
} else { } else {
......
...@@ -130,7 +130,7 @@ class SyncSupplierService ...@@ -130,7 +130,7 @@ class SyncSupplierService
'company_name' => $supplier['supplier_name'], 'company_name' => $supplier['supplier_name'],
'company_tax_no' => $supplier['tax_number'], 'company_tax_no' => $supplier['tax_number'],
'init_nature' => Arr::get(config('fixed.SupplierGroup'), $supplier['supplier_group']), 'init_nature' => Arr::get(config('fixed.SupplierGroup'), $supplier['supplier_group']),
'region' => $supplier['region'] == 2 ? 1 : 2, 'region' => $supplier['region'] == SupplierChannelModel::REGION_CN ? 1 : 2,
'pi_file_url' => $fileUrl ?: '', 'pi_file_url' => $fileUrl ?: '',
]; ];
(new QueueDeliveryService())->push(QueueDeliveryService::PUSH_TYPE_SYNC_HTTP, '/sync/Company/syncCompany', (new QueueDeliveryService())->push(QueueDeliveryService::PUSH_TYPE_SYNC_HTTP, '/sync/Company/syncCompany',
......
...@@ -13,6 +13,7 @@ use App\Http\Services\ViewCheckService; ...@@ -13,6 +13,7 @@ use App\Http\Services\ViewCheckService;
use App\Model\IntracodeModel; use App\Model\IntracodeModel;
use App\Model\LogModel; use App\Model\LogModel;
use App\Model\RedisModel; use App\Model\RedisModel;
use App\Model\SupplierChannelModel;
use App\Model\SupplierContactModel; use App\Model\SupplierContactModel;
use App\Model\SupplierExtendModel; use App\Model\SupplierExtendModel;
...@@ -255,7 +256,7 @@ class SupplierTransformer ...@@ -255,7 +256,7 @@ class SupplierTransformer
$channel['city_id'] = !empty($regionData[1]) ? $regionData[1] : 0; $channel['city_id'] = !empty($regionData[1]) ? $regionData[1] : 0;
} }
//判断所在区域,如果不是中国,则要把省市去掉 //判断所在区域,如果不是中国,则要把省市去掉
if ($channel['region'] != 2) { if ($channel['region'] != SupplierChannelModel::REGION_CN) {
$channel['province_id'] = $channel['city_id'] = 0; $channel['province_id'] = $channel['city_id'] = 0;
} }
unset($channel['province_city']); unset($channel['province_city']);
...@@ -271,6 +272,12 @@ class SupplierTransformer ...@@ -271,6 +272,12 @@ class SupplierTransformer
unset($channel[$key]); unset($channel[$key]);
} }
} }
//国内才有税号
if ($channel['region']!=SupplierChannelModel::REGION_CN) {
$channel['tax_number'] = '';
}
$channel['attachment'] = $attachment; $channel['attachment'] = $attachment;
return $channel; return $channel;
} }
......
...@@ -20,10 +20,11 @@ class SupplierValidator ...@@ -20,10 +20,11 @@ class SupplierValidator
//整理下请求数据 //整理下请求数据
$validateData = $this->transformRequestData($validateData); $validateData = $this->transformRequestData($validateData);
//这个要优先判断 //没有忽略校验的权限并且供应商地区属于内地和港台才会去校验天眼查
if (!checkPerm('IgnoreCompanyCheck')) { if (!checkPerm('IgnoreCompanyCheck') && in_array($validateData['supplier_group'],
config('field.NeedCheckCompanyRegion'))) {
$needCheckFlag = false; $needCheckFlag = false;
//新增的,都要去校验,然后修改的话,如果没有集团编码,并且是标准添加(非标准添加,即是特殊权限添加,不需要校验),也要去校验 //新增的校验,然后修改的话,如果没有集团编码,并且是标准添加(非标准添加,即是特殊权限添加,不需要校验),也要去校验
if (empty($validateData['supplier_id'])) { if (empty($validateData['supplier_id'])) {
$needCheckFlag = true; $needCheckFlag = true;
} }
...@@ -36,7 +37,7 @@ class SupplierValidator ...@@ -36,7 +37,7 @@ class SupplierValidator
} }
} }
if ($needCheckFlag) { if ($needCheckFlag) {
$regionType = $validateData['region'] == 2 ? 1 : 2; $regionType = $validateData['region'] == SupplierChannelModel::REGION_CN ? 1 : 2;
//还要校验提交上来的公司是否有合法信息 //还要校验提交上来的公司是否有合法信息
$companyInfo = (new CompanyService())->getCompanyInfo($validateData['supplier_name'], $companyInfo = (new CompanyService())->getCompanyInfo($validateData['supplier_name'],
$validateData['tax_number'], $validateData['tax_number'],
......
...@@ -37,6 +37,9 @@ class SupplierChannelModel extends Model ...@@ -37,6 +37,9 @@ class SupplierChannelModel extends Model
const SUPPLIER_GROUP_ORIGINAL = 1; //原厂 const SUPPLIER_GROUP_ORIGINAL = 1; //原厂
const SUPPLIER_GROUP_PROXY = 4; //代理 const SUPPLIER_GROUP_PROXY = 4; //代理
//供应商地区
const REGION_CN = 2; //国内
//黑名单信息 //黑名单信息
public function blacklist() public function blacklist()
......
...@@ -182,5 +182,6 @@ return [ ...@@ -182,5 +182,6 @@ return [
'NeedSkipSupplierNameCheckIds' => [ 'NeedSkipSupplierNameCheckIds' => [
195, 195,
12263 12263
] ],
'NeedCheckCompanyRegion' => [2, 4]
]; ];
\ No newline at end of file
...@@ -57,6 +57,8 @@ ...@@ -57,6 +57,8 @@
self.next('#supplier_check_tip').find('p').text(res.err_msg); self.next('#supplier_check_tip').find('p').text(res.err_msg);
$('#supplier_name').prop('disabled', false); $('#supplier_name').prop('disabled', false);
} }
} else if (res.err_code === -3) {
//跳过天眼查校验
} else { } else {
//这个code代表供应商名称已经存在,自然要检测 //这个code代表供应商名称已经存在,自然要检测
layer.msg(res.err_msg, {icon: 5}); layer.msg(res.err_msg, {icon: 5});
...@@ -77,6 +79,7 @@ ...@@ -77,6 +79,7 @@
$('#supplier_address').val(companyInfo.supplier_address); $('#supplier_address').val(companyInfo.supplier_address);
$('#registered_capital').val(companyInfo.registered_capital); $('#registered_capital').val(companyInfo.registered_capital);
layer.msg('校验公司信息通过,自动补全相关数据', {icon: 6}) layer.msg('校验公司信息通过,自动补全相关数据', {icon: 6})
if (!ignoreCompanyCheck) { if (!ignoreCompanyCheck) {
if (self.attr('id') === 'supplier_name') { if (self.attr('id') === 'supplier_name') {
$('#tax_number').attr('disabled', true); $('#tax_number').attr('disabled', true);
...@@ -135,9 +138,11 @@ ...@@ -135,9 +138,11 @@
@endif @endif
if (data.value === '2') { if (data.value === '2') {
$('#tax_number_required_span').show(); $('#tax_number_required_span').show();
$('#tax_number_div').show();
$('.city-div').show(); $('.city-div').show();
} else { } else {
$('#tax_number_required_span').hide(); $('#tax_number_required_span').hide();
$('#tax_number_div').hide();
$('.city-div').hide(); $('.city-div').hide();
} }
}); });
...@@ -311,7 +316,7 @@ ...@@ -311,7 +316,7 @@
$('#registered_capital').val(companyInfo.registered_capital); $('#registered_capital').val(companyInfo.registered_capital);
form.render(); form.render();
layer.msg('验证成功,校验公司信息通过,自动补全相关数据', {icon: 6}) layer.msg('验证成功,校验公司信息通过,自动补全相关数据', {icon: 6})
} else { } else if (res.err_code === -1) {
if (ignoreCompanyCheck) { if (ignoreCompanyCheck) {
layer.msg('公司未进行工商注册', {icon: 5}) layer.msg('公司未进行工商注册', {icon: 5})
} else { } else {
......
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="layui-col-md2" style="padding-left: 20px"> <div class="layui-col-md2" style="padding-left: 40px">
<button type="button" class="layui-btn layui-btn-sm" id="recheck_company_info">重新查验公司信息</button> <button type="button" class="layui-btn layui-btn-sm" id="recheck_company_info">重新查验公司信息</button>
</div> </div>
</div> </div>
......
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="layui-col-md2" style="padding-left: 20px"> <div class="layui-col-md2" style="padding-left: 40px">
<button type="button" class="layui-btn layui-btn-sm" id="recheck_company_info">重新查验公司信息</button> <button type="button" class="layui-btn layui-btn-sm" id="recheck_company_info">重新查验公司信息</button>
</div> </div>
</div> </div>
......
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