Commit c483e6a1 by mushishixian

只能选采购员

parent 5759f1fe
...@@ -61,8 +61,8 @@ class SupplierContactController extends Controller ...@@ -61,8 +61,8 @@ class SupplierContactController extends Controller
$this->data['receipt'] = $model->where('contact_id', $contactId)->first()->toArray(); $this->data['receipt'] = $model->where('contact_id', $contactId)->first()->toArray();
} }
$intracodeModel = new IntracodeModel(); $intracodeModel = new IntracodeModel();
$userCodes = $intracodeModel->getSampleEncode(); // $userCodes = $intracodeModel->getSampleEncode();
$this->data['userCodes'] = $userCodes; $this->data['userCodes'] = $intracodeModel->getChannelUsersEncode();
return $this->view('添加联系方式'); return $this->view('添加联系方式');
} }
...@@ -74,7 +74,7 @@ class SupplierContactController extends Controller ...@@ -74,7 +74,7 @@ class SupplierContactController extends Controller
$model = new SupplierContactModel(); $model = new SupplierContactModel();
$this->data['contact'] = $model->where('contact_id', $contactId)->first()->toArray(); $this->data['contact'] = $model->where('contact_id', $contactId)->first()->toArray();
$intracodeModel = new IntracodeModel(); $intracodeModel = new IntracodeModel();
$userCodes = $intracodeModel->getSampleEncode(); $userCodes = $intracodeModel->getChannelUsersEncode();
$this->data['userCodes'] = $userCodes; $this->data['userCodes'] = $userCodes;
return $this->view('添加联系方式'); return $this->view('添加联系方式');
} }
......
...@@ -58,7 +58,7 @@ class SupplierController extends Controller ...@@ -58,7 +58,7 @@ class SupplierController extends Controller
public function SupplierList($request) public function SupplierList($request)
{ {
$intracodeModel = new IntracodeModel(); $intracodeModel = new IntracodeModel();
$this->data['userCodes'] = $intracodeModel->getSampleEncode(); $this->data['userCodes'] = $intracodeModel->getChannelUsersEncode();
$this->data['users'] = $intracodeModel->getAdminUserAndCode(); $this->data['users'] = $intracodeModel->getAdminUserAndCode();
$supplierStatisticsService = new SupplierStatisticsService(); $supplierStatisticsService = new SupplierStatisticsService();
$statistics = $supplierStatisticsService->getSupplierListStatistics(); $statistics = $supplierStatisticsService->getSupplierListStatistics();
...@@ -99,7 +99,7 @@ class SupplierController extends Controller ...@@ -99,7 +99,7 @@ class SupplierController extends Controller
$intracodeModel = new IntracodeModel(); $intracodeModel = new IntracodeModel();
$this->data['outside_contact_status'] = Config('fixed.OutsideContactStatus'); $this->data['outside_contact_status'] = Config('fixed.OutsideContactStatus');
$this->data['outside_contact_type'] = Config('fixed.OutsideContactType'); $this->data['outside_contact_type'] = Config('fixed.OutsideContactType');
$userCodes = $intracodeModel->getSampleEncode(); $userCodes = $intracodeModel->getChannelUsersEncode();
$this->data['userCodes'] = $userCodes; $this->data['userCodes'] = $userCodes;
$this->data['user'] = $userCodes; $this->data['user'] = $userCodes;
$this->data['purchase_users'] = []; $this->data['purchase_users'] = [];
...@@ -131,7 +131,7 @@ class SupplierController extends Controller ...@@ -131,7 +131,7 @@ class SupplierController extends Controller
{ {
$intracodeModel = new IntracodeModel(); $intracodeModel = new IntracodeModel();
$userCodes = $intracodeModel->getSampleEncode(); $userCodes = $intracodeModel->getSampleEncode();
$this->data['userCodes'] = $userCodes; $this->data['userCodes'] = $intracodeModel->getChannelUsersEncode();
$this->data['user'] = $userCodes; $this->data['user'] = $userCodes;
$this->data['purchase_users'] = []; $this->data['purchase_users'] = [];
$this->data['operate'] = 'update'; $this->data['operate'] = 'update';
...@@ -183,7 +183,7 @@ class SupplierController extends Controller ...@@ -183,7 +183,7 @@ class SupplierController extends Controller
$supplier = $transformer->transformInfo($supplier); $supplier = $transformer->transformInfo($supplier);
$this->data['supplier'] = $supplier; $this->data['supplier'] = $supplier;
$intracodeModel = new IntracodeModel(); $intracodeModel = new IntracodeModel();
$this->data['userCodes'] = $intracodeModel->getPurchaseUserCodes(); $this->data['userCodes'] = $intracodeModel->getChannelUsersEncode();
$logModel = new LogModel(); $logModel = new LogModel();
$this->data['logs'] = $logModel->where('supplier_id', $supplierId) $this->data['logs'] = $logModel->where('supplier_id', $supplierId)
->where('action', '分配渠道开发员')->orderBy('id', 'desc') ->where('action', '分配渠道开发员')->orderBy('id', 'desc')
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace App\Model; namespace App\Model;
use App\Http\Services\AdminUserService; use App\Http\Services\AdminUserService;
use App\Http\Services\DepartmentService;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
class IntracodeModel extends Model class IntracodeModel extends Model
...@@ -16,7 +17,8 @@ class IntracodeModel extends Model ...@@ -16,7 +17,8 @@ class IntracodeModel extends Model
$codeList = json_decode($redis->get('EncodedList_supplier'), true); $codeList = json_decode($redis->get('EncodedList_supplier'), true);
if (!$codeList) { if (!$codeList) {
$codeList = $this->where('admin_id', '>', 0)->join('user_info', 'lie_intracode.admin_id', '=', $codeList = $this->where('admin_id', '>', 0)->join('user_info', 'lie_intracode.admin_id', '=',
'user_info.userId')->select('code_id', 'admin_id', 'name', 'email')->get(); 'user_info.userId')->where('user_info.status', '!=', 4)->select('code_id', 'admin_id', 'name',
'email')->get();
if ($codeList) { if ($codeList) {
$codeList = $codeList->toArray(); $codeList = $codeList->toArray();
foreach ($codeList as $k => &$v) { foreach ($codeList as $k => &$v) {
...@@ -31,6 +33,7 @@ class IntracodeModel extends Model ...@@ -31,6 +33,7 @@ class IntracodeModel extends Model
return $codeList; return $codeList;
} }
//获取简单的内部用户数据 //获取简单的内部用户数据
public function getSampleEncode() public function getSampleEncode()
{ {
...@@ -42,13 +45,22 @@ class IntracodeModel extends Model ...@@ -42,13 +45,22 @@ class IntracodeModel extends Model
return $result; return $result;
} }
//获取开发员的编码(渠道开发部门的优先排序) //获取采购员和对应的编码
public function getAdminIdEncode() public function getChannelUsersEncode()
{ {
$codeList = $this->getEncode(); $departmentService = new DepartmentService();
//市场部
$usersMarket = $departmentService->getUserByDepartmentId(4);
//运营部
$usersOperation = $departmentService->getUserByDepartmentId(9);
//采购部
$userChannel = $departmentService->getUserByDepartmentId(8);
$users = array_merge(array_merge($usersMarket, $usersOperation),$userChannel);
$userIds = array_column($users, 'userId');
$users = $this->getEncodeByUserIds($userIds);
$result = []; $result = [];
foreach ($codeList as $code) { foreach ($users as $code) {
$result[$code['admin_id']] = $code['name'] . '(' . $code['code_id'] . ')'; $result[$code['code_id']] = $code['name'] . '(' . $code['code_id'] . ')';
} }
return $result; return $result;
} }
...@@ -88,7 +100,7 @@ class IntracodeModel extends Model ...@@ -88,7 +100,7 @@ class IntracodeModel extends Model
} }
$temp = []; $temp = [];
foreach ($codes as $code => $name) { foreach ($codes as $code => $name) {
if (in_array($code,$codeIds)) { if (in_array($code, $codeIds)) {
unset($codes[$code]); unset($codes[$code]);
$temp[$code] = $name; $temp[$code] = $name;
} }
...@@ -102,7 +114,7 @@ class IntracodeModel extends Model ...@@ -102,7 +114,7 @@ class IntracodeModel extends Model
{ {
$encodedUsers = []; $encodedUsers = [];
$codes = $this->select('code_id', 'admin_id') $codes = $this->select('code_id', 'admin_id')
->whereIn('code_id',$encodedList) ->whereIn('code_id', $encodedList)
->get(); ->get();
if (empty($codes)) { if (empty($codes)) {
return []; return [];
...@@ -110,8 +122,8 @@ class IntracodeModel extends Model ...@@ -110,8 +122,8 @@ class IntracodeModel extends Model
$codes = $codes->toArray(); $codes = $codes->toArray();
$adminIds = array_column($codes, 'admin_id'); $adminIds = array_column($codes, 'admin_id');
$userModel = new UserInfoModel(); $userModel = new UserInfoModel();
$users = $userModel->whereIn('userId',$adminIds)->pluck('name', 'userId'); $users = $userModel->whereIn('userId', $adminIds)->pluck('name', 'userId');
foreach ($codes as $key=>$code) { foreach ($codes as $key => $code) {
$encodedUsers[$code['code_id']] = array_get($users, $code['admin_id']); $encodedUsers[$code['code_id']] = array_get($users, $code['admin_id']);
} }
return $encodedUsers; return $encodedUsers;
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
area: ['600px', '525px'], area: ['600px', '525px'],
title: '新增联系人', title: '新增联系人',
end: function () { // 监听弹窗关闭 end: function () { // 监听弹窗关闭
location.href = '/supplier/UpdateSupplier?view=iframe&tab=contact&supplier_id='+supplierId; // location.href = '/supplier/UpdateSupplier?view=iframe&tab=contact&supplier_id='+supplierId;
table.reload('contactList'); table.reload('contactList');
} }
}); });
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
area: ['600px', '525px'], area: ['600px', '525px'],
title: '编辑联系人', title: '编辑联系人',
end: function () { // 监听弹窗关闭 end: function () { // 监听弹窗关闭
location.href = '/supplier/UpdateSupplier?view=iframe&tab=contact&supplier_id='+supplierId; // location.href = '/supplier/UpdateSupplier?view=iframe&tab=contact&supplier_id='+supplierId;
table.reload('contactList'); table.reload('contactList');
} }
}); });
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
return false; return false;
} }
if (resp.err_code === 0) { if (resp.err_code === 0) {
location.href = '/supplier/UpdateSupplier?view=iframe&tab=contact&supplier_id='+supplierId; // location.href = '/supplier/UpdateSupplier?view=iframe&tab=contact&supplier_id='+supplierId;
table.reload('contactList'); table.reload('contactList');
layer.closeAll(); layer.closeAll();
layer.msg(resp.err_msg, {'icon': 6}); layer.msg(resp.err_msg, {'icon': 6});
......
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