Commit c088387d by 杨树贤

修改忽略审核

parent 2c8811a0
...@@ -161,27 +161,16 @@ class SupplierApiController extends Controller ...@@ -161,27 +161,16 @@ class SupplierApiController extends Controller
if (!$supplierId) { if (!$supplierId) {
$this->response(-1, '操作失败'); $this->response(-1, '操作失败');
} }
//如果是申请审核,还要去修改审核状态
if ($isAudit) {
$supplierService = new SupplierService();
$auditData[] = [
'supplier_id' => $supplierId,
//供应商类型为临时供应商,才会去存申请理由
'apply_audit_reason' => $channel['supplier_type'] == 2 ? $request->input('apply_audit_reason') : '',
];
$supplierService->batchApplyInReviewSupplier($auditData);
}
$this->response(0, '操作成功'); $this->response(0, '操作成功');
} }
//添加供应商 //更新供应商
public function UpdateSupplier($request) public function UpdateSupplier($request)
{ {
//先去表单验证 //先去表单验证
$validator = new SupplierValidator(); $validator = new SupplierValidator();
$data = $request->all(); $data = $request->all();
$isAudit = (bool)$request->input('is_audit'); $isAudit = (bool)$request->input('is_audit');
$supplierId = $request->input('supplier_id');
$validateResult = $validator->checkSave($data, $isAudit); $validateResult = $validator->checkSave($data, $isAudit);
if ($validateResult) { if ($validateResult) {
$this->response(-1, $validateResult); $this->response(-1, $validateResult);
...@@ -193,16 +182,6 @@ class SupplierApiController extends Controller ...@@ -193,16 +182,6 @@ class SupplierApiController extends Controller
if (!$result) { if (!$result) {
$this->response(-1, '修改失败'); $this->response(-1, '修改失败');
} }
//如果是申请审核,还要去修改审核状态,
if ($isAudit) {
$supplierService = new SupplierService();
$auditData[] = [
'supplier_id' => $supplierId,
//供应商类型为临时供应商,才会去存申请理由
'apply_audit_reason' => $channel['supplier_type'] == 2 ? $request->input('apply_audit_reason') : '',
];
$supplierService->batchApplyInReviewSupplier($auditData);
}
$this->response(0, $isAudit ? '申请审核成功' : '修改成功'); $this->response(0, $isAudit ? '申请审核成功' : '修改成功');
} }
......
...@@ -64,10 +64,10 @@ class SupplierAuditService ...@@ -64,10 +64,10 @@ class SupplierAuditService
if ($result) { if ($result) {
//如果状态是复审 //如果状态是复审
if ($supplier['status'] == SupplierChannelModel::STATUS_NEED_REVIEW) { if ($supplier['status'] == SupplierChannelModel::STATUS_NEED_REVIEW) {
$auditStatus = $status == SupplierChannelModel::STATUS_PASSED ? '复审通过 '.$rejectReason : '复审不通过,原因是 : ' . $rejectReason; $auditStatus = $status == SupplierChannelModel::STATUS_PASSED ? '复审通过 ' . $rejectReason : '复审不通过,原因是 : ' . $rejectReason;
$action = '复审供应商'; $action = '复审供应商';
} else { } else {
$auditStatus = $status == SupplierChannelModel::STATUS_PASSED ? '审核通过 '.$rejectReason : '审核不通过,原因是 : ' . $rejectReason; $auditStatus = $status == SupplierChannelModel::STATUS_PASSED ? '审核通过 ' . $rejectReason : '审核不通过,原因是 : ' . $rejectReason;
} }
$logService = new LogService(); $logService = new LogService();
$content = $auditStatus; $content = $auditStatus;
...@@ -229,7 +229,7 @@ class SupplierAuditService ...@@ -229,7 +229,7 @@ class SupplierAuditService
return true; return true;
} }
//判断是否要进入审核中状态,因为部分字段修改是不需要走审核的 //判断是否要进入审核中状态,因为部分字段修改是不需要走审核的,这是更新之前的校验
public function checkNeedAudit($supplierId, $channel) public function checkNeedAudit($supplierId, $channel)
{ {
$notNeedAuditField = [ $notNeedAuditField = [
...@@ -261,7 +261,6 @@ class SupplierAuditService ...@@ -261,7 +261,6 @@ class SupplierAuditService
//如果有忽略审核的权限并且不需要复审,那么状态就是不需要审核直接通过 //如果有忽略审核的权限并且不需要复审,那么状态就是不需要审核直接通过
$canIgnoreAudit = $this->checkCanIgnoreSupplierAudit($supplierId); $canIgnoreAudit = $this->checkCanIgnoreSupplierAudit($supplierId);
if ($canIgnoreAudit) { if ($canIgnoreAudit) {
return false; return false;
} }
...@@ -271,10 +270,24 @@ class SupplierAuditService ...@@ -271,10 +270,24 @@ class SupplierAuditService
$changeField[] = $key; $changeField[] = $key;
} }
} }
foreach ($changeField as $filed) { foreach ($changeField as $field) {
//只要有一个不存在于不需要审核的字段,就返回需要审核 //只要有一个不存在于不需要审核的字段,就返回需要审核
if (!in_array($filed, $notNeedAuditField)) { if (!in_array($field, $notNeedAuditField)) {
return true; return true;
} else {
if ($field === 'stockup_type') {
//还要单独判断供应商的stockup_type,只有是操作云芯这个值的时候,才不去审核,真是服了
$oldStockupType = explode(',', trim($supplier['stockup_type'], ''));
$newStockupType = explode(',', trim($channel['stockup_type'], ''));
if (count($oldStockupType) > count($newStockupType)) {
$modifyStockupType = array_diff($oldStockupType, $newStockupType);
} else {
$modifyStockupType = array_diff($newStockupType, $oldStockupType);
}
if (array_values($modifyStockupType) != ['5']) {
return true;
}
}
} }
} }
return false; return false;
......
...@@ -72,8 +72,10 @@ class SupplierService ...@@ -72,8 +72,10 @@ class SupplierService
$oldSupplier = $model->where('supplier_id', $channel['supplier_id'])->first(); $oldSupplier = $model->where('supplier_id', $channel['supplier_id'])->first();
$oldSupplier = $supplierTransformer->transformInfo($oldSupplier); $oldSupplier = $supplierTransformer->transformInfo($oldSupplier);
} }
$needAudit = true;
//走事务 //走事务
$supplierId = DB::connection('web')->transaction(function () use ($channel, $model, $oldSupplier) { $supplierId = DB::connection('web')->transaction(function () use ($channel, $model, $oldSupplier, &$needAudit) {
//是否直接申请审核 //是否直接申请审核
$isDirectApply = request()->get('direct_apply'); $isDirectApply = request()->get('direct_apply');
...@@ -106,7 +108,6 @@ class SupplierService ...@@ -106,7 +108,6 @@ class SupplierService
$skuAuditRulerService = new SupplierSkuAuditRulerService(); $skuAuditRulerService = new SupplierSkuAuditRulerService();
$channel['sku_audit_ruler'] = $skuAuditRulerService->getSkuAuditRulerForDB($channel['sku_audit_ruler']); $channel['sku_audit_ruler'] = $skuAuditRulerService->getSkuAuditRulerForDB($channel['sku_audit_ruler']);
//新增供应商操作 //新增供应商操作
if (empty($channel['supplier_id'])) { if (empty($channel['supplier_id'])) {
//处理附件信息,新增的时候才会有附件信息提交过来 //处理附件信息,新增的时候才会有附件信息提交过来
...@@ -212,7 +213,6 @@ class SupplierService ...@@ -212,7 +213,6 @@ class SupplierService
//要做进一步判断,部分字段修改不需要审核 //要做进一步判断,部分字段修改不需要审核
$auditService = new SupplierAuditService(); $auditService = new SupplierAuditService();
$needAudit = $auditService->checkNeedAudit($supplierId, $channel); $needAudit = $auditService->checkNeedAudit($supplierId, $channel);
if ($needAudit) { if ($needAudit) {
$channel['status'] = SupplierChannelModel::STATUS_PENDING; $channel['status'] = SupplierChannelModel::STATUS_PENDING;
} else { } else {
...@@ -220,7 +220,6 @@ class SupplierService ...@@ -220,7 +220,6 @@ class SupplierService
$syncService = new SyncSupplierService(); $syncService = new SyncSupplierService();
$syncService->syncSupplierToErp($supplierId); $syncService->syncSupplierToErp($supplierId);
} }
$channel['update_time'] = time(); $channel['update_time'] = time();
//这里有个逻辑,就是如果供应商类型是临时,那么要打上临时供应商的标签,如果不是,那么就要去掉这个标签 //这里有个逻辑,就是如果供应商类型是临时,那么要打上临时供应商的标签,如果不是,那么就要去掉这个标签
...@@ -244,7 +243,6 @@ class SupplierService ...@@ -244,7 +243,6 @@ class SupplierService
} }
$channel['system_tags'] = trim(implode(',', $channel['system_tags']), ','); $channel['system_tags'] = trim(implode(',', $channel['system_tags']), ',');
$model->where('supplier_id', $supplierId)->update($channel); $model->where('supplier_id', $supplierId)->update($channel);
//保存地址 //保存地址
$supplierAddressService = new SupplierAddressService(); $supplierAddressService = new SupplierAddressService();
...@@ -280,7 +278,7 @@ class SupplierService ...@@ -280,7 +278,7 @@ class SupplierService
$mainBrands = explode(',', $mainBrands); $mainBrands = explode(',', $mainBrands);
$mainBrands = array_map(function ($value) { $mainBrands = array_map(function ($value) {
return (int)$value; return (int)$value;
},$mainBrands); }, $mainBrands);
$supplierSkuCpTimeRuler = $redis->hget('supplier_sku_upload_ruler_v2', $supplierId); $supplierSkuCpTimeRuler = $redis->hget('supplier_sku_upload_ruler_v2', $supplierId);
if ($supplierSkuCpTimeRuler) { if ($supplierSkuCpTimeRuler) {
$supplierSkuCpTimeRuler = json_decode($supplierSkuCpTimeRuler, true); $supplierSkuCpTimeRuler = json_decode($supplierSkuCpTimeRuler, true);
...@@ -327,6 +325,19 @@ class SupplierService ...@@ -327,6 +325,19 @@ class SupplierService
'old_supplier' => $oldSupplier, 'old_supplier' => $oldSupplier,
'new_supplier' => $newSupplier 'new_supplier' => $newSupplier
])); ]));
//这里有个申请审核的判断逻辑
//如果是申请审核,还要去修改审核状态
$isAudit = (bool)request()->input('is_audit');
if ($isAudit && $needAudit) {
$auditData[] = [
'supplier_id' => $supplierId,
//供应商类型为临时供应商,才会去存申请理由
'apply_audit_reason' => $channel['supplier_type'] == 2 ? request()->input('apply_audit_reason') : '',
];
$this->batchApplyInReviewSupplier($auditData);
}
return $supplierId; return $supplierId;
} }
...@@ -653,8 +664,22 @@ class SupplierService ...@@ -653,8 +664,22 @@ class SupplierService
if (!$result) { if (!$result) {
return $result; return $result;
} }
//新增一条申请审核的日志 }
// (new LogService())->AddLog($data['supplier_id'], LogModel::UPDATE_OPERATE, '申请审核', '申请审核供应商'); return true;
}
//申请审核供应商
public function applyInReviewSupplier($supplierId, $channel)
{
$model = new SupplierChannelModel();
$needAudit = (new SupplierAuditService())->checkNeedAudit($supplierId, $channel);
$result = $model->where('supplier_id', $data['supplier_id'])->update([
'update_time' => time(),
'apply_audit_reason' => $data['apply_audit_reason'],
'status' => SupplierChannelModel::STATUS_IN_REVIEW
]);
if (!$result) {
return $result;
} }
return true; return true;
} }
......
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