Commit cd093441 by mushishixian

离职下拉

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