Commit c9e9d2fc by 杨树贤

忽略审核权限

parent 25bfdf2a
......@@ -186,8 +186,8 @@ class SupplierApiController extends Controller
if (!$result) {
$this->response(-1, '修改失败');
}
//如果是申请审核,还要去修改审核状态
if ($isAudit) {
//如果是申请审核,还要去修改审核状态,如果是忽略更新审核的话,也没必要走下面的步骤
if ($isAudit && !checkPerm('IgnoreUpdateAudit')) {
$supplierService = new SupplierService();
$auditData[] = [
'supplier_id' => $supplierId,
......
......@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Http\Services\LogService;
use App\Http\Services\SupplierAttachmentService;
use App\Http\Services\SupplierAuditService;
use App\Http\Transformers\SupplierAttachmentTransformer;
use App\Http\Validators\SupplierAttachmentValidator;
use App\Model\LogModel;
......@@ -53,14 +54,18 @@ class SupplierAttachmentApiController extends Controller
'attachment_id',
]);
$attachmentService = new SupplierAttachmentService();
$result = $attachmentService->saveAttachment($attachment);
if (!$result) {
$supplierId = $attachmentService->saveAttachment($attachment);
if (!$supplierId) {
$this->response(-1, '操作失败');
} else {
SupplierChannelModel::where('supplier_id', $attachment['supplier_id'])->update([
'update_time' => time(),
'status' => SupplierChannelModel::STATUS_PENDING,
]);
$canIgnoreAudit = (new SupplierAuditService())->checkCanIgnoreSupplierAudit($supplierId);
if (!$canIgnoreAudit) {
SupplierChannelModel::where('supplier_id', $supplierId)->update([
'update_time' => time(),
'status' => SupplierChannelModel::STATUS_PENDING,
]);
}
$logService = new LogService();
$content = !empty($attachment['attachment_id']) ? '修改附件信息' : '添加附件信息';
$remark = json_encode($attachment);
......
......@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Http\Services\LogService;
use App\Http\Services\SupplierAuditService;
use App\Http\Transformers\LogTransformer;
use App\Http\Transformers\ReceiptTransformer;
use App\Http\Validators\ReceiptValidator;
......@@ -101,6 +102,13 @@ class SupplierReceiptApiController extends Controller
$notNeedAuditField = [
'remark',
];
//如果有忽略审核的权限并且不需要复审,那么状态就是不需要审核直接通过
$canIgnoreAudit = (new SupplierAuditService())->checkCanIgnoreSupplierAudit($oldReceipt['supplier_id']);
if ($canIgnoreAudit) {
return false;
}
$diff = array_diff($oldReceipt, $newReceipt);
unset($diff['update_time']);
$changeField = array_keys($diff);
......
......@@ -41,7 +41,7 @@ class SupplierAttachmentService
return $attachmentModel->insertGetId($attachment);
} else {
$attachment['update_time'] = time();
return $attachmentModel->where('attachment_id', $attachmentId)->update($attachment);
return $attachmentModel->where('attachment_id', $attachmentId)->update($attachment)?$attachment['supplier_id']:0;
}
}
......
......@@ -236,6 +236,7 @@ class SupplierAuditService
'sku_tag',
'sku_upload_ruler',
'sku_audit_ruler',
'need_review'
];
//先找出目前数据库里面的数据
$selectField = array_keys($channel);
......@@ -247,6 +248,12 @@ class SupplierAuditService
}
$supplier = $model->select($selectField)->where('supplier_id', $supplierId)->first()->toArray();
//如果有忽略审核的权限并且不需要复审,那么状态就是不需要审核直接通过
if (checkPerm('IgnoreUpdateAudit') && !$supplier['need_review']) {
return false;
}
$changeField = [];
foreach ($supplier as $key => $value) {
if ($value != $channel[$key]) {
......@@ -261,4 +268,17 @@ class SupplierAuditService
}
return false;
}
//判断是否可以直接忽略修改审核
public function checkCanIgnoreSupplierAudit($supplierId)
{
$needReview = SupplierChannelModel::where('supplier_id', $supplierId)->value('need_review');
//如果有忽略审核的权限并且不需要复审,那么状态就是不需要审核直接通过
if (!checkPerm('IgnoreUpdateAudit') && !$needReview) {
return true;
}else{
return false;
}
}
}
\ No newline at end of file
......@@ -131,6 +131,13 @@ class SupplierContactService
'supplier_qq',
'supplier_fax',
];
//如果有忽略审核的权限并且不需要复审,那么状态就是不需要审核直接通过
$canIgnoreAudit = (new SupplierAuditService())->checkCanIgnoreSupplierAudit($oldContact['supplier_id']);
if ($canIgnoreAudit) {
return false;
}
$diff = array_merge(array_diff($oldContact, $newContact), array_diff($newContact, $oldContact));
unset($diff['update_time']);
$changeField = array_keys($diff);
......@@ -177,9 +184,10 @@ class SupplierContactService
$contact['admin_id'] = request()->user->userId;
$result = $contactModel->insert($contact);
if ($result) {
$channelUids = $contacts = $contactModel->where('supplier_id',$supplierId)->pluck('can_check_uids')->toArray();
$channelUids = $contacts = $contactModel->where('supplier_id',
$supplierId)->pluck('can_check_uids')->toArray();
$supplierModel = new SupplierChannelModel();
$result = $supplierModel->where('supplier_id',$supplierId)->update([
$result = $supplierModel->where('supplier_id', $supplierId)->update([
'channel_uid' => implode(',', $channelUids),
'update_time' => time(),
]);
......
......@@ -128,6 +128,7 @@ class SupplierService
} else {
$channel['status'] = SupplierChannelModel::STATUS_PENDING;
}
//第一次新增的供应商,都需要进行复审
$channel['need_review'] = 1;
......@@ -184,7 +185,7 @@ class SupplierService
/**这里的是更新供应商的操作**/
$supplierId = $this->newSupplierId = $channel['supplier_id'];
$supplier = SupplierChannelModel::where('supplier_id', $supplierId)->first()->toArray();
//要做进一步判断,部分字段修改不需要审核
$auditService = new SupplierAuditService();
$needAudit = $auditService->checkNeedAudit($supplierId, $channel, $attachment);
......
......@@ -81,9 +81,12 @@
<button type="button" class="layui-btn layui-btn submit-loading" lay-submit
lay-filter="updateSupplier">确认修改供应商
</button>
<button type="button" class="layui-btn layui-btn submit-loading" lay-submit
lay-filter="applyAuditSupplier">申请审核
</button>
@if (!checkPerm('IgnoreUpdateAudit'))
<button type="button" class="layui-btn layui-btn submit-loading" lay-submit
lay-filter="applyAuditSupplier">申请审核
</button>
@endif
@endif
<a id="supplierDetailUrl"
href="/supplier/SupplierDetail?view=iframe&supplier_id={{$supplier['supplier_id']}}"
......
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