Commit 1724f4fb by 杨树贤

批量修改采购员的审核跳过问题

parent 060e9c63
......@@ -440,7 +440,6 @@ class SupplierApiController extends Controller
$this->response(-1, '该采购员已经离职,请选择其他人员');
}
$supplierIds = explode(',', $supplierIds);
$model = new SupplierChannelModel();
foreach ($supplierIds as $supplierId) {
$service = new SupplierService();
$result = $service->allocateChannelUser($supplierId, $channelUid);
......
......@@ -426,7 +426,7 @@ class SupplierService
}
//分配采购员
public function allocateChannelUser($supplierId, $channelUid, $logFlag = true)
public function allocateChannelUser($supplierId, $channelUid, $needLog = true)
{
$supplier = SupplierChannelModel::where('supplier_id', $supplierId)->first();
if (empty($supplier)) {
......@@ -438,9 +438,8 @@ class SupplierService
if (in_array($channelUid, $preChannelUid)) {
return true;
}
$result = DB::connection('web')->transaction(function () use ($supplierId, $channelUid, $logFlag) {
$model = new SupplierChannelModel();
$supplier = $model->where('supplier_id', $supplierId)->first();
$result = DB::connection('web')->transaction(function () use ($supplierId, $channelUid, $needLog) {
$supplier = SupplierChannelModel::where('supplier_id', $supplierId)->first();
$supplier = $supplier ? $supplier->toArray() : [];
$preChannelUid = $supplier['channel_uid'];
$preChannelUid = explode(',', $preChannelUid);
......@@ -448,17 +447,23 @@ class SupplierService
$preChannelUid = array_unique($preChannelUid);
$preChannelUid = implode(',', $preChannelUid);
$preChannelUid = trim($preChannelUid, ',');
if ($logFlag) {
$result = $model->where('supplier_id', $supplierId)->update([
if ($needLog) {
$data = [
'update_time' => time(),
'channel_uid' => $preChannelUid,
]);
];
//还要判断是否要进入审核状态,如果有忽略分配采购员进入审核的权限,那么就不用进入待审核状态
if (!checkPerm('IgnoreAllocateChannelUserAudit')) {
$data['status'] = SupplierChannelModel::STATUS_IN_REVIEW;
}
$result = SupplierChannelModel::where('supplier_id', $supplierId)->update($data);
} else {
$result = $model->where('supplier_id', $supplierId)->update([
$result = SupplierChannelModel::where('supplier_id', $supplierId)->update([
'channel_uid' => $preChannelUid,
]);
}
$contactResult = false;
if ($result) {
$contactModel = new SupplierContactModel();
......@@ -470,7 +475,7 @@ class SupplierService
];
$contactResult = $contactModel->insert($contact);
}
if ($contactResult && $logFlag) {
if ($contactResult && $needLog) {
//判断是否是非正式(is_type=1)供应商,如果是,自动转正,并且修改为待审核状态
$this->autoChangeIsType($supplier);
//记录日志
......
......@@ -148,15 +148,16 @@
},
{
field: 'status_name', title: '状态', align: 'center', width: 80, templet: function (data) {
if (data.status === 3) {
switch (data.status) {
case 3:
return "<span style='color: red' title='" + data.reject_reason + "'>" + data.status_name + "</span>"
} else if (data.status === -3) {
case -3:
return "<span style='color: red' title='" + data.block_reason + "'>" + data.status_name + "</span>"
} else {
case -2:
return "<span style='color: red' title='" + data.disable_reason + "'>" + data.status_name + "</span>"
default:
return data.status_name;
}
switch (data.status){
case 3:
}
}
},
......
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