Commit 95413a20 by mushishixian

修改联系人忽略审核字段

parent efaacd21
......@@ -67,7 +67,6 @@ class SupplierAuditService
->where('type', LogModel::UPDATE_OPERATE)->orderBy('id', 'desc')->first();
$supplier['last_update_'] = $log['admin_name'] ?: '无';
$lastUpdateUserId = $log['admin_id'];
}
//判断是否为待跟进供应商
......@@ -97,7 +96,7 @@ class SupplierAuditService
public function checkHasAllRequireField($supplier)
{
//先检查基础字段
if (empty($supplier['supplier_name']) || empty($supplier['register_company_name'] || empty($supplier['region']) || empty($supplier['legal_representative']))) {
if (empty($supplier['supplier_name']) || empty($supplier['region']) || empty($supplier['legal_representative'])) {
return false;
}
if (empty($supplier['stockup_type']) || empty($supplier['supplier_group']) || empty($supplier['qualification_photos'])) {
......@@ -121,4 +120,35 @@ class SupplierAuditService
}
return true;
}
//判断是否要进入待审核状态,因为部分字段修改是不需要走审核的
public function checkNeedAudit($supplierId, $channel)
{
$notNeedAuditField = [
'register_company_name',
'supplier_name_en',
'province_id',
'city_id',
'established_time',
'credit_investigation'
];
//先找出目前数据库里面的数据
$selectField = array_keys($channel);
$model = new SupplierChannelModel;
$supplier = $model->select($selectField)->where('supplier_id', $supplierId)->first()->toArray();
$changeField = [];
foreach ($supplier as $key => $value) {
if ($value != $channel[$key]) {
$changeField[] = $key;
}
}
foreach ($changeField as $filed) {
//只要有一个不存在于不需要审核的字段,就返回需要审核
if (!in_array($filed, $notNeedAuditField)) {
return true;
}
}
return false;
}
}
\ No newline at end of file
......@@ -46,16 +46,11 @@ class SupplierContactService
//还要将采购的数据整理重新写入
$supplierId = $contact['supplier_id'];
$supplierModel = new SupplierChannelModel();
$channelUid = $supplierModel->where('supplier_Id', $supplierId)->value('channel_uid');
$channelUid = explode(',', $channelUid);
$channelUid = array_filter($channelUid, function ($value) {
return !empty($value);
});
if (!empty($contact['contact_id'])) {
$contact['update_time'] = time();
$contactId = $contact['contact_id'];
$result = $model->where('contact_id', $contact['contact_id'])->update($contact);
$oldContact = $model->where('contact_id', $contact['contact_id'])->first()->toArray();
$result = $model->where('contact_id', $contact['contact_id'])->update($contact);
} else {
$oldContact = [];
$contact['add_time'] = time();
......@@ -68,7 +63,7 @@ class SupplierContactService
if (!empty($canCheckUids)) {
$canCheckUids = array_unique($canCheckUids->toArray());
$canCheckUids = implode(',', $canCheckUids);
}else{
} else {
$canCheckUids = '';
}
......@@ -77,31 +72,46 @@ class SupplierContactService
'update_time' => time(),
]);
$newContact = $model->where('contact_id', $contactId)->first()->toArray();
if ($result) {
//修改供应商为审核状态
$supplierModel = new SupplierChannelModel();
$supplierStatus = $supplierModel->where('supplier_id', $contact['supplier_id'])->value('status');
//不等于-1的时候是第一次新增供应商,单独操作联系人,不需要修改状态
if ($supplierStatus != SupplierChannelModel::STATUS_PENDING) {
//如果修改的只是qq和传真,则不需要转成审核
$needAudit = $this->checkNeedAudit($oldContact, $newContact);
if ($needAudit || empty($contact['contact_id'])) {
//修改供应商为审核状态
$supplierModel->where('supplier_id', $contact['supplier_id'])->update([
'update_time' => time(),
'status' => 1,
]);
}
//待审核(没有完善过联系人的,不需要记录日志,让其继续保持一条日志,就叫新增供应商)
if ($supplierStatus != SupplierChannelModel::STATUS_PENDING) {
$logService = new LogService();
$content = !empty($contact['contact_id']) ? '修改联系人' : '添加联系人';
$remark = json_encode([
'old_contact' => $oldContact,
'new_contact' => $newContact,
]);
$logService->AddLog($contact['supplier_id'], LogModel::UPDATE_OPERATE, '修改供应商基本资料', $content, $remark);
}
$logService = new LogService();
$content = !empty($contact['contact_id']) ? '修改联系人' : '添加联系人';
$remark = json_encode([
'old_contact' => $oldContact,
'new_contact' => $newContact,
]);
$logService->AddLog($contact['supplier_id'], LogModel::UPDATE_OPERATE, '修改供应商基本资料', $content, $remark);
}
return $result;
}
//判断是否要进入待审核状态,因为部分字段修改是不需要走审核的
private function checkNeedAudit($oldContact, $newContact)
{
$notNeedAuditField = [
'supplier_qq',
'supplier_fax',
];
$diff = array_diff($oldContact, $newContact);
unset($diff['update_time']);
$changeField = array_keys($diff);
foreach ($changeField as $filed) {
//只要有一个不存在于不需要审核的字段,就返回需要审核
if (!in_array($filed, $notNeedAuditField)) {
return true;
}
}
return false;
}
}
\ No newline at end of file
......@@ -148,7 +148,11 @@ class SupplierService
} else {
$supplierId = $this->newSupplierId = $channel['supplier_id'];
//要做进一步判断,部分字段修改不需要审核
$channel['status'] = SupplierChannelModel::STATUS_IN_REVIEW;
$auditService = new SupplierAuditService();
$needAudit = $auditService->checkNeedAudit($supplierId, $channel);
if ($needAudit) {
$channel['status'] = SupplierChannelModel::STATUS_IN_REVIEW;
}
$channel['update_time'] = time();
$model->where('supplier_id', $supplierId)->update($channel);
$this->saveSupplierCode($supplierId);
......
......@@ -42,7 +42,7 @@ class SupplierContactValidator
$count = $query->where('contact_id', '!=', $data['contact_id'])->count();
}
if ($count) {
return '供应商已经存在手机号或者邮箱一样的联系人,请联系管理人员查看具体详情';
return '原厂或者代理商性质的供应商不允许重复的联系人,<br>该供应商已经存在手机号或者邮箱一样的联系人,请联系管理人员查看具体详情';
}
}
......
......@@ -98,7 +98,7 @@
elem: '.city-selector',
data: {!! json_encode($region_data) !!},
title: '所在省市 : ',
name : 'region',
name : 'region_test',
// primary_key: 'region_id', // 主键字段
// parent_key: 'parent_id', // 父级字段
// title_key: 'region_name', // 标题字段
......
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