Commit 105b40a5 by mushishixian

自动转正

parent 6640143b
......@@ -298,6 +298,7 @@ class SupplierApiController extends Controller
}
//批量修改渠道开发员
//修改后自动触发转正,资料不完善,进入待审核
public function BatchAllocatePurchaseUser($request)
{
$purchaseUid = $request->get('purchase_uid');
......
......@@ -107,7 +107,7 @@ class SupplierFilter
$canViewAllSupplier = checkPerm('ViewAllSupplier');
$canViewSubordinateSupplier = checkPerm('ViewSubordinateSupplier');
$canViewFakeSupplier = checkPerm('ViewFakeSupplier');
//现在普通采购也能看到竞调供应商了(与他有关的)
if (!$canViewFakeSupplier) {
$query->where('is_type', 0);
}
......@@ -189,11 +189,13 @@ class SupplierFilter
case "no_purchase_uid":
//没有渠道开发
$query->where('status', '!=', SupplierChannelModel::STATUS_DISABLE)
->where('status', '!=', SupplierChannelModel::STATUS_BLOCK)
->where('purchase_uid', '');
break;
case "no_channel_uid":
//没有渠道开发
//没有采购员
$query->where('status', '!=', SupplierChannelModel::STATUS_DISABLE)
->where('status', '!=', SupplierChannelModel::STATUS_BLOCK)
->where('channel_uid', '');
break;
case "invalid_channel_uid":
......@@ -250,12 +252,14 @@ class SupplierFilter
//联系人待完善
case "contact_no_complete":
$query->whereHas('contact', function ($q) {
$q->where('supplier_consignee', '')
$q->where('can_check_uids', request()->user->codeId)->where(function ($subQuery) {
$subQuery->where('supplier_consignee', '')
->orWhere('supplier_position', '')
->orWhere('supplier_email', '')
->orWhere('supplier_mobile', '')
->orWhere('supplier_telephone', '');
});
});
break;
}
return $query;
......
......@@ -251,6 +251,7 @@ class SupplierService
//分配开发员
public function allocatePurchaseUser($supplierId, $purchaseUid)
{
$result = DB::connection('web')->transaction(function () use ($supplierId, $purchaseUid) {
$model = new SupplierChannelModel();
$supplier = $model->where('supplier_id', $supplierId)->first();
$supplier = $supplier ? $supplier->toArray() : [];
......@@ -269,6 +270,8 @@ class SupplierService
'to_follow_up' => 1,
]);
}
//判断是否是非正式供应商,如果是,自动转正,并且修改为待审核状态
$this->autoChangeIsType($supplier);
}
//还要去记录日志
......@@ -282,6 +285,8 @@ class SupplierService
$logService->AddLog($supplierId, LogModel::UPDATE_OPERATE, '分配渠道开发员', $content);
}
});
return $result;
}
......@@ -297,6 +302,7 @@ class SupplierService
//分配采购员
public function allocateChannelUser($supplierId, $channelUid)
{
$result = DB::connection('web')->transaction(function () use ($supplierId, $channelUid) {
$model = new SupplierChannelModel();
$supplier = $model->where('supplier_id', $supplierId)->first();
$supplier = $supplier ? $supplier->toArray() : [];
......@@ -318,6 +324,8 @@ class SupplierService
$contactResult = $contactModel->insert($contact);
}
if ($contactResult) {
//判断是否是非正式供应商,如果是,自动转正,并且修改为待审核状态
$this->autoChangeIsType($supplier);
//记录日志
$adminUserService = new AdminUserService();
$channelUser = $adminUserService->getAdminUserInfoByCodeId($channelUid);
......@@ -326,9 +334,11 @@ class SupplierService
$content = "添加采购员 : " . $channelUserName;
$logService->AddLog($supplierId, LogModel::UPDATE_OPERATE, '添加采购员', $content);
}
return $contactResult;
});
$syncService = new SyncSupplierService();
$syncService->syncSupplierToErp($supplierId);
return $contactResult;
return $result;
}
//判断并且修改待跟进
......@@ -403,4 +413,17 @@ class SupplierService
}
return true;
}
//判断是否自动转正,并且还要修改为待审核状态给相关人员进行补充资料
public function autoChangeIsType($supplier)
{
if ($supplier['is_type'] == 1) {
$model = new SupplierChannelModel();
$model->where('supplier_id', $supplier['supplier_id'])->update([
'update_time' => time(),
'status' => 0,
'is_type' => 0
]);
}
}
}
\ No newline at end of file
......@@ -52,6 +52,11 @@ return [
'SkuMode' => [
1 => '原厂直供',
2 => '国内现货',
3 => '国际现货',
4 => '猎芯期货',
5 => '海外代购',
6 => '线下现货',
7 => '猎芯自营',
],
'SupplierAccountType' => [
......
......@@ -10,21 +10,18 @@
</blockquote>
<table class="layui-table">
<colgroup>
<col width="300">
<col width="100">
<col>
<col>
</colgroup>
<thead>
<tr>
<th>供应商名称</th>
<th>当前渠道开发员</th>
</tr>
</thead>
<tbody>
@foreach($suppliers as $supplier)
<tr>
<td>{{$supplier['supplier_name']}}</td>
<td>{{$supplier['purchase_username']}}</td>
</tr>
@endforeach
</tbody>
......
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