Commit 95df392e by 杨树贤

对接一体化标签

parent e03df99c
......@@ -173,6 +173,14 @@ class SupplierApiController extends Controller
$this->response(-1, '该供应商为实体名单,不允许建档');
}
if ($checkCompanyEntity == -2) {
$this->response(-1, '该供应商为黑名单,不允许建档');
}
if ($checkCompanyEntity == -3) {
$this->response(-1, '该供应商被驳回,不允许建档');
}
//如果是有直接新增权限的(绕过天眼查等校验)
if (checkPerm('IgnoreCompanyCheck')) {
$channel['is_standard_add'] = -1;
......
......@@ -18,6 +18,7 @@ use App\Model\LogModel;
use App\Model\SupplierChannelModel;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use function foo\func;
class SupplierController extends Controller
{
......@@ -213,14 +214,18 @@ class SupplierController extends Controller
$this->data['province_city'] = [$supplier['province_id'], $supplier['city_id']];
//获取标签情况
$tagService = new SupplierTagService();
$systemTags = $tagService->getTagsBySupplierId($supplierId, 1);
$systemTags = $tagService->getSystemTagsBySupplierId($supplierId, 1);
$supplier['system_tags'] = array_map(function ($value) {
return [
'tag_name' => $value,
];
}, $systemTags);
$customerTags = $tagService->getTagsBySupplierId($supplierId, 2);
$supplier['system_tags'] = $systemTags ? implode(',', $systemTags) : '';
$supplier['customer_tags'] = $customerTags ? implode(',', $customerTags) : '';
$supplierModel = new SupplierChannelModel();
$supplierModel->where('supplier_id', $supplierId)->update([
'customer_tags' => $supplier['customer_tags'],
'system_tags' => $supplier['system_tags'],
]);
$this->data['supplier'] = $supplier;
$this->data['address'] = $supplierService->getAddress($supplierId);
......@@ -403,4 +408,4 @@ class SupplierController extends Controller
return $this->view('查询供应商');
}
}
\ No newline at end of file
}
......@@ -14,7 +14,7 @@ class BaseSyncController extends Controller
{
public function syncResponse($code = 0, $msg = '成功', $data = '', $count = 0)
{
header('Content-Type: application/json');
echo json_encode([
'code' => $code,
'msg' => $msg,
......
......@@ -56,8 +56,26 @@ class SupplierSyncController extends BaseSyncController
$resultData = $request->only([
'company_name',
'result',
'result_map',
'tag_list'
]);
Log::error(json_encode($resultData));
$resultData['result_map'] = !empty($resultData['result_map']) ? json_decode($resultData['result_map'], true) : [];
$resultData['tag_list'] = !empty($resultData['tag_list']) ? json_decode($resultData['tag_list'], true) : [];
if (is_array($resultData['result_map'])) {
$resultData['result'] = (int)$resultData['result_map'][1];
}
if ($resultData['result'] !== 0 && empty($resultData)) {
$this->syncResponse(-1, '没有获取到正确的类型');
}
if (!in_array($resultData['result'], [0, 1, -1, -2, -3])) {
$this->syncResponse(-1, '非法公司分类');
}
$rules = [
"company_name" => "required",
//"result" => "required",
......@@ -69,7 +87,6 @@ class SupplierSyncController extends BaseSyncController
$error = $validator->errors()->first();
$this->syncResponse(-1, $error);
}
//这里还要去判断是是拉黑
if ($resultData['result'] == -2) {
$data['status'] = SupplierChannelModel::STATUS_BLOCK;
......@@ -81,7 +98,7 @@ class SupplierSyncController extends BaseSyncController
$this->syncResponse(0, '获取审核结果广播成功');
}
(new SyncSupplierService())->receiveEntityResult($resultData['company_name'], $resultData['result']);
(new SyncSupplierService())->receiveEntityResult($resultData['company_name'], $resultData['result'], $resultData['tag_list']);
$this->syncResponse(0, '获取审核结果广播成功');
}
......
......@@ -88,6 +88,7 @@ class CompanyService
'company_name_en' => $supplierNameEn,
'register_address' => $supplierAddress,
'business_license' => $businessLicense,
'company_id' => 1,
];
$url = config('website.UnitedDataDomain') . '/sync/Company/checkCompanyEntity';
$result = curl($url, $params);
......
......@@ -54,6 +54,15 @@ class SupplierTagService
return !empty($data['data']) ? $data['data'] : [];
}
public function getSystemTagsBySupplierId($supplierId)
{
$supplier = SupplierChannelModel::where('supplier_id', $supplierId)->select(['system_tags', 'united_tags'])
->first()->toArray();
$systemTags = $supplier['system_tags']?explode(',',$supplier['system_tags']):[];
$unitedTags = $supplier['united_tags']?explode(',',$supplier['united_tags']):[];
return array_merge($systemTags, $unitedTags);
}
//新增/修改标签和供应商id对应关系到标签系统
public function saveTags($supplierId, $tagUse, $newTags, $oldTags)
......
......@@ -221,7 +221,7 @@ class SyncSupplierService
//接收一体化的广播信息,对供应商进行实体名单操作
//加入实体名单后,要做很多事情,比如禁用供应商,也要禁用供应商账号等等,还要记录禁用之前的状态,等到移除实体名单以后,要恢复之前的状态
public function receiveEntityResult($supplierName, $result)
public function receiveEntityResult($supplierName, $result, $tagList)
{
Log::warning('一体化拉黑结果 : ' . ($supplierName . '---' . $result));
//先找到对应的供应商(草稿的跳过),如果没有那跳过
......@@ -245,10 +245,15 @@ class SyncSupplierService
if ($result == -1) {
$isEntityResult = SupplierChannelModel::IS_ENTITY_TRUE;
$logContent = $reason = '属于实体名单,系统自动拉入黑名单';
} else {
}
if ($result == 0) {
$isEntityResult = SupplierChannelModel::IS_ENTITY_NEED_CONFIRM;
$logContent = $reason = '待确认实体名单,系统自动拉入禁止交易,请联系“风控部门”进行确认';
}
if ($result == -3) {
$isEntityResult = SupplierChannelModel::IS_ENTITY_REJECT;
$logContent = $reason = '被驳回供应商,系统自动拉入禁止交易,请联系“风控部门”进行确认';
}
}
$preStatus = null;
$redis = new RedisModel();
......@@ -277,6 +282,7 @@ class SyncSupplierService
//这里的逻辑是,因为取消实体名单以后,如果之前的状态是黑名单的话,直接变成待提审
'status' => $isEntity ? SupplierChannelModel::STATUS_DISABLE : ($preStatus == SupplierChannelModel::STATUS_BLOCK ? SupplierChannelModel::STATUS_IN_REVIEW : $preStatus),
'disable_reason' => $reason,
'united_tags' => !empty($tagList) ? implode(',', $tagList) : '',
]);
$isYunxinSupplier = false;
//还要去修改对应的供应商账号,也是要记录禁用前的状态
......
......@@ -356,26 +356,25 @@
},
pageSize: 30,
data: tagList,
on: function (tagList) {
let arr = tagList.arr;
let tagIds = '';
for (let i in arr) {
tagIds += arr[i].tag_id + ',';
}
let idName = 'system_tags';
$('#' + idName).val(tagIds);
},
// on: function (tagList) {
// let arr = tagList.arr;
// let tagIds = '';
// for (let i in arr) {
// tagIds += arr[i].tag_id + ',';
// }
// let idName = 'system_tags';
// $('#' + idName).val(tagIds);
// },
};
}
if (supplierId) {
@if (checkPerm('UpdateSupplierTags'))
let systemTagOption = getTagOption('system_tags_selector', 2);
let systemTagOption = getTagOption('system_tags_selector');
systemTagOption.disabled = true;
let tagSelector = xmSelect.render(systemTagOption);
let tagIds = $('#system_tags').attr('value');
tagSelector.setValue(tagIds.split(','));
// let tagIds = $('#system_tags').attr('value');
tagSelector.setValue({!! json_encode(!empty($supplier['system_tags'])?$supplier['system_tags']:[]) !!});
//自定义标签
$('#customer_tags').tagsInput({});
@endif
......
......@@ -269,6 +269,12 @@
@endif
<span class="layui-btn layui-btn-xs">{{$tag}}</span>
@endforeach
@foreach (explode(',',$supplier['united_tags']) as $tag)
@if (empty($tag))
@continue
@endif
<span class="layui-btn layui-btn-xs">{{$tag}}</span>
@endforeach
</div>
<div class="layui-col-md12">
自定义标签 :
......
......@@ -310,7 +310,7 @@
<div class="layui-input-block" style="margin-top: 15px">
<div id="system_tags_selector" class="layui-input-inline" style="width: 100%;">
</div>
<input type="hidden" name="system_tags" value="{{$supplier['system_tags'] or ''}}"
<input type="hidden" name="system_tags"
id="system_tags">
</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