Commit ea9e9cd9 by 杨树贤

完成前端以及部分接口

parent 93930231
......@@ -16,7 +16,7 @@ class SupplierAccountFilter
{
$map = $request->all();
$model = new SupplierAccountModel();
$query = $model->where('parent_id', 0)->orderBy('id', 'desc');
$query = $model->with('supplier')->where('parent_id', 0)->orderBy('id', 'desc');
if (!checkPerm('ViewAllSupplierAccount')) {
if (checkPerm('ViewSubSupplierAccount')) {
......
......@@ -79,4 +79,30 @@ class CompanyService
}
return $company;
}
}
\ No newline at end of file
//校验是否实体名单通过
public function checkCompanyEntity($supplierName, $supplierNameEn, $supplierAddress, $businessLicense)
{
$params = [
'company_name_cn' => $supplierName,
'company_name_en' => $supplierNameEn,
'register_address' => $supplierAddress,
'business_license' => $businessLicense,
];
$url = config('website.UnitedDataDomain') . '/sync/Company/checkCompanyEntity';
$result = curl($url, $params);
$result = json_decode($result, true);
if (array_get($result, 'code') === 0) {
if ($result['data']['result'] == -1) {
return '该供应商为实体名单,不允许建档';
}
if ($result['data']['result'] == 0) {
return '该供应商是否属于实体名单还在待验证种,暂时无法新建';
}
return true;
}
return '一体化校验实体名单失败,请联系管理员';
}
}
......@@ -83,7 +83,7 @@ class SupplierService
//走事务
$supplierId = DB::connection('web')->transaction(function () use ($channel, $model, $oldSupplier, &$needAudit) {
//是否直接申请审核
//是否直接申请审核,如果是直接申请审核,那就变成待审核
$isDirectApply = request()->get('direct_apply');
$tagService = new SupplierTagService();
......@@ -113,8 +113,10 @@ class SupplierService
//sku上传规则相关设置
$skuAuditRulerService = new SupplierSkuAuditRulerService();
$channel['sku_audit_ruler'] = $skuAuditRulerService->getSkuAuditRulerForDB($channel['sku_audit_ruler']);
/**新增供应商操作**/
if (empty($channel['supplier_id'])) {
//处理附件信息,新增的时候才会有附件信息提交过来
$attachmentField = [
'file_name',
......@@ -184,6 +186,7 @@ class SupplierService
//插入供应商返回供应商id
$supplierId = $this->newSupplierId = $model->insertGetId($channel);
$this->saveSkuUploadRulerToRedis($supplierId, $channel['sku_upload_ruler']);
//添加联系人
//要有数据才新增,麻烦得要死
if (!checkArrayAllValueNull($contact)) {
......
......@@ -4,7 +4,9 @@
namespace App\Http\Services;
//后台用户相关信息服务
use App\Model\LogModel;
use App\Model\RedisModel;
use App\Model\SupplierAccountModel;
use App\Model\SupplierAttachmentsModel;
use App\Model\SupplierChannelModel;
use App\Model\SupplierContactModel;
......@@ -208,6 +210,75 @@ class SyncSupplierService
return SupplierChannelModel::where('group_code', $groupCode)
->update($data);
}
}
//接收一体化的广播信息,对供应商进行实体名单操作
//加入实体名单后,要做很多事情,比如禁用供应商,也要禁用供应商账号等等,还要记录禁用之前的状态,等到移除实体名单以后,要恢复之前的状态
public function receiveEntityResult($supplierName, $result)
{
//先找到对应的供应商,如果没有那跳过
$supplier = SupplierChannelModel::where('supplier_name', $supplierName)->first();
if (empty($supplier)) {
return;
}
$supplier = $supplier->toArray();
$supplierId = $supplier['supplier_id'];
//先把修改之前的状态给记录下来
$status = $supplier['status'];
//然后根据result,修改供应商的是否是实体名单字段
$isEntity = $result == 1 ? false : true;
//我这里的状态和一体化的结果判断有点对不上,因为我这把是(是否实体名单),而一体化那边是实体名单是否通过,所以要转换
if ($result == 1) {
$isEntityResult = SupplierChannelModel::IS_ENTITY_FALSE;
$logContent = $reason = '属于实体名单,系统自动拉入黑名单';
} else {
if ($result == -1) {
$isEntityResult = SupplierChannelModel::IS_ENTITY_TRUE;
$logContent = $reason = '';
} else {
$isEntityResult = SupplierChannelModel::IS_ENTITY_NEED_CONFIRM;
$logContent = $reason = '待确认实体名单,系统自动拉入禁止交易,请联系“风控部门”进行确认';
}
}
$preStatus = null;
$redis = new RedisModel();
if ($isEntity) {
$redis->hset('supplier_status_before_disable', $supplierId, $status);
} else {
$preStatus = $redis->hget('supplier_status_before_disable', $supplierId);
$redis->hdel('supplier_status_before_disable', $supplierId, $status);
}
SupplierChannelModel::where('supplier_id', $supplierId)->update([
'is_entity' => $isEntityResult,
'update_time' => time(),
'status' => $isEntity ? SupplierChannelModel::STATUS_DISABLE : $preStatus,
'disable_reason' => $reason,
]);
//还要去修改对应的供应商账号,也是要记录禁用前的状态
$supplierAccount = SupplierAccountModel::where('supplier_id', $supplierId)->first();
if ($supplierAccount) {
$supplierAccount = $supplierAccount->toArray();
$accountPreStatus = $supplierAccount['a_status'];
if ($isEntity) {
$redis->hset('supplier_account_status_before_disable', $supplierId, $accountPreStatus);
} else {
$accountPreStatus = $redis->hget('supplier_account_status_before_disable', $supplierId);
$redis->hdel('supplier_status_before_disable', $supplierId, $accountPreStatus);
}
SupplierAccountModel::where('supplier_id', $supplierId)->update([
'update_time' => time(),
'a_status' => $isEntity ? SupplierAccountModel::STATUS_DISABLE : $accountPreStatus,
]);
}
//还要去打日志
if ($isEntity) {
$logService = new LogService();
$logService->AddLog($supplierId, LogModel::UPDATE_OPERATE, '实体名单设置', $logContent);
}
}
}
......@@ -50,6 +50,7 @@ class SupplierTransformer
$supplier['status_name'] = array_get(config('fixed.SupplierStatus'), $supplier['status']);
$supplier['supplier_type_name'] = array_get(config('field.SupplierType'), $supplier['supplier_type']);
$supplier['company_nature_name'] = array_get(config('field.CompanyNature'), $supplier['company_nature']);
$supplier['is_entity_name'] = array_get(config('field.IsEntity'), $supplier['is_entity'], '暂无');
$supplier['region_name'] = array_get(config('fixed.Region'), $supplier['region'], '暂无');
$supplier['contact_num'] = $this->getContactNum($supplier['supplier_id']);
$supplier['has_sku'] = $supplier['sku_num'] ? '是' : '否';
......
......@@ -26,7 +26,7 @@ class SupplierValidator
return null;
}
$isAdd = empty($validateData['supplier_id']) ? true : false;
$isAdd = empty($validateData['supplier_id']);
if (!$validateData['supplier_name']) {
return '供应商名称不能为空';
......@@ -74,6 +74,13 @@ class SupplierValidator
}
}
//去一体化那边判断是否是合法实体名单审核
$businessLicense = '';
$checkCompanyEntity = (new CompanyService())->checkCompanyEntity($validateData['supplier_name'], $validateData['supplier_name_en'], $validateData['supplier_address'], $businessLicense);
if ($checkCompanyEntity !== true) {
return $checkCompanyEntity;
}
//这个supplierId是用来判断是新增还是修改的
$supplierId = array_get($validateData, 'supplier_id');
//如果是修改直接提交,不是点申请审核的,只需要校验供应商名称和采购员是否完整即可
......@@ -145,18 +152,6 @@ class SupplierValidator
];
$errorMessageList = [];
//主营品牌数量的判断
// if ($validateData['main_brands_limit_type'] == 1) {
// if (!$validateData['main_brands_limit']) {
// $errorMessageList[] = '主营品牌限制数量不能为空';
// }
//
// if (count(explode(',', trim($validateData['main_brands'], ','))) > $validateData['main_brands_limit']) {
// $errorMessageList[] = '主营品牌数量大于设置的限制数量';
// }
// }
//判断供应商类型,如果类型为临时,而且名字属于不能修改为临时的代购供应商列表里面,就要报错
if (empty($validateData['supplier_type'])) {
......@@ -409,4 +404,4 @@ class SupplierValidator
}
return $validateData;
}
}
\ No newline at end of file
}
......@@ -10,4 +10,11 @@ class SupplierAccountModel extends Model
protected $table='yunxin_account';
protected $primaryKey = 'id';
public $timestamps = false;
const STATUS_DISABLE = 0;
public function supplier()
{
return $this->belongsTo(SupplierChannelModel::class,'supplier_id','supplier_id');
}
}
......@@ -44,6 +44,11 @@ class SupplierChannelModel extends Model
//有上传过SKU
const HAS_UPLOADED_SKU = 1;
//是否是实体名单
const IS_ENTITY_NEED_CONFIRM = 0;
const IS_ENTITY_TRUE = 1;
const IS_ENTITY_FALSE = -1;
//黑名单信息
public function blacklist()
......
......@@ -304,5 +304,12 @@ return [
3 => '日韩',
4 => '港台',
5 => '其它',
],
'IsEntity' => [
-1 => '否',
0 => '待确认',
1 => '是'
]
];
......@@ -273,5 +273,6 @@ return [
'CertificationStatus' => [
-1 => '非认证',
1 => '认证',
]
],
];
......@@ -52,6 +52,7 @@
.list-href:hover {
color: #1417F4;
}
</style>
<body>
<!-- 正文开始 -->
......
......@@ -42,6 +42,14 @@
{field: 'supplier_name', title: '供应商名称', align: 'center'},
{field: 'type_name', title: '账号类型', align: 'center'},
{
field: 'is_entity', title: '实体名单', align: 'center', width: 80, templet: function (data) {
if (data.supplier) {
return data.supplier.is_entity === -1 ? '否' : "<span style='color: red' title='" + data.supplier.disbale_reason + "'></span>";
}
return '否';
}
},
{
field: 'a_status', title: '状态', align: 'center', width: 80, templet: function (data) {
return data.a_status === 1 ? '启用' : "<span style='color: red'>禁用</span>"
}
......
......@@ -150,6 +150,23 @@
width: 120,
},
{
field: 'is_entity', title: '实体名单', align: 'center', width: 80, templet: function (data) {
let color = '';
switch (data.is_entity) {
case 1:
color = '#FF0000';
break;
case 0:
color = '#FFA500';
break;
default:
color = '';
}
return '<span style="color: ' + color + '">' + data.is_entity_name + '</span>';
}
},
{
field: 'contact_num', title: '联系人', align: 'center', width: 70, templet: function (data) {
return "<a ew-href='/supplier/SupplierDetail?view=iframe&tab=contact&supplier_id=" + data.supplier_id +
"' class='list-href' ew-title='供应商详情 - " + data.supplier_code + "' title='点击跳转查看联系人列表'>" + data.contact_num + "</a>"
......
......@@ -76,13 +76,12 @@
<a id="updateSupplierUrl"
style="margin-bottom: 25px;margin-top: 5px" class="layui-btn layui-btn">修改</a>
@endif
@if($supplier['status']==\App\Model\SupplierChannelModel::STATUS_DISABLE)
@if($supplier['status']==\App\Model\SupplierChannelModel::STATUS_DISABLE && $supplier['is_entity']==\App\Model\SupplierChannelModel::IS_ENTITY_FALSE)
@if (checkPerm('CancelDisableSupplier'))
<button id="cancel_disable_supplier"
style="margin-bottom: 25px;margin-top: 5px" class="layui-btn layui-btn">取消禁用
</button>
@endif
@endif
@if($supplier['status']==\App\Model\SupplierChannelModel::STATUS_IN_REVIEW)
<button type="button" style="margin-bottom: 25px;margin-top: 5px"
......@@ -179,10 +178,6 @@
</div>
<div class="layui-row">
<span class="required_field">*</span> 主营品牌 :{{$supplier['main_brand_names']}}
{{-- <div style="">--}}
{{-- 主营品牌数量--}}
{{-- :{{$supplier['main_brands_limit']!=-1?$supplier['main_brands_limit']:'无限制'}}--}}
{{-- </div>--}}
</div>
@if($supplier['supplier_group'] == \App\Model\SupplierChannelModel::SUPPLIER_GROUP_MIX)
<div class="layui-row">
......@@ -220,7 +215,7 @@
到票时间 :{{$supplier['ticket_time']}}
</div>
<div class="layui-col-md3">
{{-- <span class="required_field">*</span> 账期详情 :{{$supplier['billing_period_detail']}}--}}
</div>
</div>
<hr/>
......@@ -343,9 +338,9 @@
</div>
<div class="layui-tab-item">
<div
@if(!checkPerm('ViewRuler'))
style="display: none"
@endif
@if(!checkPerm('ViewRuler'))
style="display: none"
@endif
>
<div class="layui-row" style="padding-bottom: 10px">
......
......@@ -87,4 +87,4 @@
target="_blank">查看</a>
@endif
</div>
</script>
\ No newline at end of file
</script>
......@@ -321,6 +321,10 @@
{!! $multiTransformableSelectPresenter->render(['has_cooperation_agreement'=>'平台合作协议'],
['has_cooperation_agreement'=>[1=>'是',-1=>'否']]) !!}
</div>
<div class="layui-inline">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('is_entity','实体名单','',config('field.IsEntity')) !!}
</div>
<div class="layui-row">
<div class="layui-inline" style="width: 600px">
@inject('transformableTimeIntervalPresenter','App\Presenters\Filter\TransformableTimeIntervalPresenter')
......
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