Commit fcdc9302 by mushishixian

ysx-供应商二期-20210610

parent 7f34beaf
......@@ -153,11 +153,11 @@ class SupplierFilter
case "all":
break;
case "pending":
//待审核供应商(其实就是没有提交审核申请的,默认是草稿
//待复审供应商
$query->where('status', SupplierChannelModel::STATUS_PENDING);
break;
case "in_review":
//待复审
//待审核
$query->where('status', SupplierChannelModel::STATUS_IN_REVIEW);
break;
case "passed":
......
......@@ -3,13 +3,10 @@
namespace App\Http\Services;
use App\Http\Transformers\SupplierTransformer;
use App\Model\LogModel;
use App\Model\RedisModel;
use App\Model\SupplierAddressModel;
use App\Model\SupplierChannelModel;
use App\Model\SupplierContactModel;
use Illuminate\Support\Facades\DB;
class SupplierAuditService
{
......@@ -18,28 +15,63 @@ class SupplierAuditService
$model = new SupplierChannelModel();
//判断当前要审核的供应商是不是想要被禁用的
//因为想要禁用,需要审核后才能禁用的,不能直接修改成禁用
//要找个地方存起来是不是想要禁用
//要找个地方存起来是不是想要禁用
$redis = new RedisModel();
$disableExist = $redis->hget('audit_disable_supplier_list', $supplierId);
if ($disableExist) {
if ($status == 2) {
if ($status == SupplierChannelModel::STATUS_PASSED) {
$status = SupplierChannelModel::STATUS_DISABLE;
} else {
$status = 2;
//因为只有通过状态的供应商才能发起禁用审核,所以拒绝禁用申请,自然会变回启用状态
$status = SupplierChannelModel::STATUS_PASSED;
}
}
//先找出原来供应商的状态
$supplierModel = new SupplierChannelModel();
$originStatus = $supplierModel->where('supplier_id', $supplierId)->value('status');
//如果原来的状态是-1,就是第一次新增的待审核,审核通过状态是变成1(待复审)
$dbStatus = $originStatus == -1 ? 1 : $status;
$result = $model->where('supplier_id', $supplierId)->update([
'update_time' => time(),
'status' => $dbStatus,
'reject_reason' => $rejectReason,
]);
$supplier = $supplierModel->where('supplier_id', $supplierId)->first()->toArray();
//如果需要复审并且审核状态为待审核,则代表这次审核为第一次审核
if ($supplier['status'] == SupplierChannelModel::STATUS_IN_REVIEW && $supplier['need_review'] == 1) {
//第一次审核,通过是将审核状态置为待复审
//通过
if ($status == SupplierChannelModel::STATUS_PASSED) {
$dbStatus = SupplierChannelModel::STATUS_PENDING;
} else {
//不通过
$dbStatus = $status;
}
$update = [
'update_time' => time(),
'status' => $dbStatus,
'reject_reason' => $rejectReason,
];
$result = $model->where('supplier_id', $supplierId)->update($update);
//如果是待复审状态,通过的话还要将是否需要复审状态置为0
} elseif ($supplier['status'] === SupplierChannelModel::STATUS_PENDING) {
if ($status == SupplierChannelModel::STATUS_PASSED) {
$update['need_review'] = 0;
$result = $model->where('supplier_id', $supplierId)->update([
'update_time' => time(),
'status' => $status,
'reject_reason' => $rejectReason,
]);
} else {
$result = $model->where('supplier_id', $supplierId)->update([
'update_time' => time(),
'status' => $status,
'reject_reason' => $rejectReason,
]);
}
//剩下的就是普通的审核
} else {
$result = $model->where('supplier_id', $supplierId)->update([
'update_time' => time(),
'status' => $status,
'reject_reason' => $rejectReason,
]);
}
if ($disableExist) {
$redis->hdel('audit_disable_supplier_list', $supplierId);
}
......@@ -48,16 +80,11 @@ class SupplierAuditService
//记录日志
if ($disableExist) {
$auditStatus = $status == SupplierChannelModel::STATUS_DISABLE ? '审核通过,禁用供应商' : '审核不通过,原因是 : ' . $rejectReason;
if ($status == SupplierChannelModel::STATUS_DISABLE) {
//发送队列消息同步到金蝶
$service = new SyncSupplierService();
$service->syncSupplierToErp($supplierId);
}
} else {
//如果原来的状态是-1,就是第一次新增的待审核,审核通过状态是变成1(待复审)
if ($originStatus == -1) {
$auditStatus = $status == SupplierChannelModel::STATUS_PASSED ? '初审通过' : '初审不通过,原因是 : ' . $rejectReason;
$action = '审供应商';
//如果状态是复审
if ($supplier['status'] == SupplierChannelModel::STATUS_PENDING) {
$auditStatus = $status == SupplierChannelModel::STATUS_PASSED ? '复审通过' : '复审不通过,原因是 : ' . $rejectReason;
$action = '审供应商';
} else {
$auditStatus = $status == SupplierChannelModel::STATUS_PASSED ? '审核通过' : '审核不通过,原因是 : ' . $rejectReason;
}
......@@ -67,8 +94,8 @@ class SupplierAuditService
$logService->AddLog($supplierId, LogModel::UPDATE_OPERATE, $action, $content);
}
//审核状态为待审核(即第一次新增)时,不需要推送到金蝶
if ($status != SupplierChannelModel::STATUS_PENDING) {
//复审通过状态的供应商才会同步到金蝶
if ($supplier['need_review'] == 1) {
//发送队列消息同步到金蝶
$service = new SyncSupplierService();
$service->syncSupplierToErp($supplierId);
......@@ -89,10 +116,12 @@ class SupplierAuditService
$auditUserId = request()->user->userId;
$logModel = new LogModel();
$log = $logModel->where('supplier_id', $supplierId)
->where('type', LogModel::UPDATE_OPERATE)->orderBy('id', 'desc')->first()->toArray();
->where('type', LogModel::UPDATE_OPERATE)->orderBy('id', 'desc')->first();
$log = $log ? $log->toArray() : [];
//判断供应商,如果是第一次新增的供应商,要去判断创建人是否属于审核人相关的部门
//别问我为啥不加多一个状态,这个审核流程是突然改成这样子的,没法加...
if ($log['action'] == '初审供应商') {
if (empty($log)) {
$lastUpdateUserId = $supplier['create_uid'];
} else {
$lastUpdateUserId = $log['admin_id'];
......@@ -173,6 +202,12 @@ class SupplierAuditService
//先找出目前数据库里面的数据
$selectField = array_keys($channel);
$model = new SupplierChannelModel;
$status = $model->where('supplier_id', $supplierId)->value('status');
//只要是未通过的,都要进入审核
if ($status == SupplierChannelModel::STATUS_REJECT) {
return true;
}
$supplier = $model->select($selectField)->where('supplier_id', $supplierId)->first()->toArray();
$changeField = [];
foreach ($supplier as $key => $value) {
......
......@@ -128,7 +128,9 @@ class SupplierService
}
return $value;
}, $channel);
$channel['status'] = SupplierChannelModel::STATUS_PENDING;
$channel['status'] = SupplierChannelModel::STATUS_IN_REVIEW;
//第一次新增的供应商,都需要进行复审
$channel['need_review'] = 1;
$contactField = [
'supplier_consignee',
'supplier_position',
......
......@@ -14,9 +14,9 @@ class SupplierStatisticsService
{
$total = $this->getStatisticsCount('all');
//待审核,就是以前的草稿
$pending = $this->getStatisticsCount('pending');
//待复审
$pending = $this->getStatisticsCount('pending');
//待审核
$inReview = $this->getStatisticsCount('in_review');
//通过
$passed = $this->getStatisticsCount('passed');
......
......@@ -10,9 +10,9 @@ class SupplierChannelModel extends Model
protected $table = 'supplier_channel';
public $timestamps = false;
//待审核(第一次新增)
//待复审(第一次新增)
const STATUS_PENDING = -1;
//待复审
//待审核
const STATUS_IN_REVIEW = 1;
//通过
const STATUS_PASSED = 2;
......
......@@ -87,8 +87,8 @@ return [
'SupplierStatus' => [
-1 => '待审核',
1 => '待复审',
-1 => '待复审',
1 => '待审核',
3 => '未通过',
2 => '已通过',
-2 => '禁止交易',
......@@ -204,8 +204,8 @@ return [
//罗盘菜单对应id
'CompassMenuMap' => [
'total' => '全部',
'pending' => '待审核',
'in_review' => '待复审',
'pending' => '待复审',
'in_review' => '待审核',
'passed' => '已通过',
'rejected' => '未通过',
'disable' => '禁止交易',
......
......@@ -35,6 +35,8 @@
$(this).attr('class', 'status_filter layui-badge layui-bg-green');
type = $(this).attr('id');
whereCondition.source_type = type
//先清空状态
whereCondition.status = 0;
table.reload('list', {
page: {
curr: 1
......@@ -224,7 +226,7 @@
return
}
// if (status === -1) {
// layer.msg('要待复审的供应商才可以审核', {icon: 5});
// layer.msg('要待审核的供应商才可以审核', {icon: 5});
// return
// }
let checkAuditMsg = checkCanAudit(supplierId);
......
......@@ -18,8 +18,10 @@
confirmMessage = '确定要重新入驻吗,该供应商就会再次进入审核阶段'
} else if (data.field.status === '-1') {
confirmMessage = '确定要提交新增供应商信息吗?一旦提交,该供应商就会进入待复审阶段,审核过程中无法进行信息修改'
}else if (data.field.status === '3') {
confirmMessage = '确定要重新提交审核吗?一旦提交,该供应商就会再次进入待审核阶段,审核过程中无法进行信息修改';
} else {
confirmMessage = '确定要修改供应商信息吗?一旦修改关键字段,该供应商就会再次进入待复审阶段,审核过程中无法进行信息修改'
confirmMessage = '确定要修改供应商信息吗?一旦修改关键字段,该供应商就会再次进入待审核阶段,审核过程中无法进行信息修改';
}
layer.confirm(confirmMessage, function (index) {
let res = ajax('/api/supplier/UpdateSupplier', data.field)
......
......@@ -58,7 +58,7 @@
@if($supplier['status']==\App\Model\SupplierChannelModel::STATUS_PENDING)
<div class="layui-row">
<button type="button" style="margin-bottom: 25px;margin-top: 5px"
class="layui-btn layui-btn layui-btn-disabled">审核,不能修改
class="layui-btn layui-btn layui-btn-disabled">复审,不能修改
</button>
</div>
@elseif($supplier['status']==\App\Model\SupplierChannelModel::STATUS_PASSED||$supplier['status']==\App\Model\SupplierChannelModel::STATUS_REJECT)
......@@ -77,7 +77,7 @@
@if($supplier['status']==\App\Model\SupplierChannelModel::STATUS_IN_REVIEW)
<div class="layui-row">
<button type="button" style="margin-bottom: 25px;margin-top: 5px"
class="layui-btn layui-btn layui-btn-disabled">复审,不能修改
class="layui-btn layui-btn layui-btn-disabled">审核,不能修改
</button>
</div>
@endif
......
......@@ -74,6 +74,10 @@
<button type="button" class="layui-btn layui-btn submit-loading" lay-submit
lay-filter="updateSupplier">确认新建供应商
</button>
@elseif($supplier['status']==\App\Model\SupplierChannelModel::STATUS_REJECT)
<button type="button" class="layui-btn layui-btn submit-loading" lay-submit
lay-filter="updateSupplier">审核未通过,确认重新提交审核
</button>
@else
<button type="button" class="layui-btn layui-btn submit-loading" lay-submit
lay-filter="updateSupplier">确认修改供应商
......
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