Commit cd093441 by mushishixian

离职下拉

parent 693c6a1e
...@@ -20,7 +20,7 @@ class SupplierTransformer ...@@ -20,7 +20,7 @@ class SupplierTransformer
public function transformList($list) public function transformList($list)
{ {
$intracodeModel = new IntracodeModel(); $intracodeModel = new IntracodeModel();
$users = $intracodeModel->getSampleEncode(); $users = $intracodeModel->getSampleEncode(true);
$supplierIds = array_column($list, 'supplier_id'); $supplierIds = array_column($list, 'supplier_id');
$viewCheckService = new ViewCheckService(); $viewCheckService = new ViewCheckService();
$viewData = $viewCheckService->checkSupplierView($supplierIds); $viewData = $viewCheckService->checkSupplierView($supplierIds);
...@@ -90,7 +90,7 @@ class SupplierTransformer ...@@ -90,7 +90,7 @@ class SupplierTransformer
return []; return [];
} }
$intracodeModel = new IntracodeModel(); $intracodeModel = new IntracodeModel();
$users = $intracodeModel->getSampleEncode(); $users = $intracodeModel->getSampleEncode(true);
$supplier['qualification_photos'] = trim($supplier['qualification_photos']); $supplier['qualification_photos'] = trim($supplier['qualification_photos']);
$supplier['stockup_type_data'] = $this->transformStockupTypeData($supplier['stockup_type']); $supplier['stockup_type_data'] = $this->transformStockupTypeData($supplier['stockup_type']);
$supplier['established_time'] = !empty($supplier['established_time']) ? date('Y-m-d', $supplier['established_time'] = !empty($supplier['established_time']) ? date('Y-m-d',
......
...@@ -11,14 +11,18 @@ class IntracodeModel extends Model ...@@ -11,14 +11,18 @@ class IntracodeModel extends Model
protected $table = 'lie_intracode'; protected $table = 'lie_intracode';
protected $primaryKey = 'code_id'; protected $primaryKey = 'code_id';
//不包含离职 //默认不包含离职
public function getEncode() public function getEncode($includeResigned = false)
{ {
$redis = new RedisModel(); $redis = new RedisModel();
$codeList = json_decode($redis->get('EncodedList_supplier'), true); $codeList = json_decode($redis->get('EncodedList_supplier_' . $includeResigned), true);
if (!$codeList) { if (!$codeList) {
$codeList = $this->where('admin_id', '>', 0)->join('user_info', 'lie_intracode.admin_id', '=', $query = $this->where('admin_id', '>', 0)->join('user_info', 'lie_intracode.admin_id', '=',
'user_info.userId')->where('user_info.status', '!=', 4)->select('code_id', 'admin_id', 'name', 'user_info.userId');
if (!$includeResigned) {
$query->where('user_info.status', '!=', 4);
}
$codeList = $query->select('code_id', 'admin_id', 'name',
'email')->get(); 'email')->get();
if ($codeList) { if ($codeList) {
$codeList = $codeList->toArray(); $codeList = $codeList->toArray();
...@@ -27,8 +31,8 @@ class IntracodeModel extends Model ...@@ -27,8 +31,8 @@ class IntracodeModel extends Model
$v['name'] = $v['email']; $v['name'] = $v['email'];
} }
} }
$redis->set('EncodedList_supplier', json_encode($codeList)); $redis->set('EncodedList_supplier_' . $includeResigned, json_encode($codeList));
$redis->expire('EncodedList_supplier', 60 * 10);//缓存10分钟 $redis->expire('EncodedList_supplier_' . $includeResigned, 60 * 10);//缓存10分钟
} }
} }
return $codeList; return $codeList;
...@@ -40,7 +44,8 @@ class IntracodeModel extends Model ...@@ -40,7 +44,8 @@ class IntracodeModel extends Model
$redis = new RedisModel(); $redis = new RedisModel();
$codeList = json_decode($redis->get('EncodedList_all_supplier'), true); $codeList = json_decode($redis->get('EncodedList_all_supplier'), true);
if (!$codeList) { if (!$codeList) {
$codeList = $this->where('admin_id', '>', 0)->join('user_info', 'lie_intracode.admin_id', '=', 'user_info.userId') $codeList = $this->where('admin_id', '>', 0)->join('user_info', 'lie_intracode.admin_id', '=',
'user_info.userId')
->select('code_id', 'admin_id', 'name', 'email')->get(); ->select('code_id', 'admin_id', 'name', 'email')->get();
if ($codeList) { if ($codeList) {
$codeList = $codeList->toArray(); $codeList = $codeList->toArray();
...@@ -57,9 +62,10 @@ class IntracodeModel extends Model ...@@ -57,9 +62,10 @@ class IntracodeModel extends Model
} }
//获取简单的内部用户数据 //获取简单的内部用户数据
public function getSampleEncode() //默认不包含离职的
public function getSampleEncode($includeResigned = false)
{ {
$codeList = $this->getEncode(); $codeList = $this->getEncode($includeResigned);
$result = []; $result = [];
foreach ($codeList as $code) { foreach ($codeList as $code) {
$result[$code['code_id']] = $code['name'] . '(' . $code['code_id'] . ')'; $result[$code['code_id']] = $code['name'] . '(' . $code['code_id'] . ')';
...@@ -88,7 +94,7 @@ class IntracodeModel extends Model ...@@ -88,7 +94,7 @@ class IntracodeModel extends Model
$usersOperation = $departmentService->getUserByDepartmentId(9); $usersOperation = $departmentService->getUserByDepartmentId(9);
//采购部 //采购部
$userChannel = $departmentService->getUserByDepartmentId(8); $userChannel = $departmentService->getUserByDepartmentId(8);
$users = array_merge(array_merge($usersMarket, $usersOperation),$userChannel); $users = array_merge(array_merge($usersMarket, $usersOperation), $userChannel);
$userIds = array_column($users, 'userId'); $userIds = array_column($users, 'userId');
$users = $this->getEncodeByUserIds($userIds); $users = $this->getEncodeByUserIds($userIds);
$result = []; $result = [];
......
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