Commit c9e9d2fc by 杨树贤

忽略审核权限

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