Commit 105b40a5 by mushishixian

自动转正

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