InfoController.class.php
2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
/**
* Created by PhpStorm.
* User: liyifei2012it
* Date: 16/9/17
* Time: 22:22
*/
namespace Apicp\Controller\User;
use Common\Common\Department;
use Common\Common\Integral;
use Common\Common\User;
use Common\Service\UserService;
class InfoController extends AbstractController
{
/**
* 【通讯录】人员详情
* @author liyifei
*/
public function Index_post()
{
$uid = I('post.uid', '', 'trim');
if (empty($uid)) {
E('_ERR_UID_IS_NULL');
}
// 用户信息
$newUser = new User();
$userInfo = $newUser->getByUid($uid, true);
// 用户属性列表
$userServ = new UserService();
$list = $userServ->userInfo($uid, $userInfo);
// 获取带层级信息的部门名称
$dpInfo = array();
foreach ($userInfo['dpName'] as $_dp) {
$dp = Department::instance()->getById($_dp['dpId']);
$dpInfo[] = $dp['departmentPath'];
}
// 用户标签信息
if (isset($userInfo['tagName']) && is_array($userInfo['tagName'])) {
$tag = array_column($userInfo['tagName'], 'tagName');
}
// 读取积分信息
$integralList = Integral::instance()->listByUid(array($uid));
$integral = current($integralList);
if (empty($integral['total'])) {
$integral['total'] = 0;
}
if (empty($integral['available'])) {
$integral['available'] = 0;
}
// 用户全公司下的排名
$userRanking = 0;
try {
$userRank = Integral::instance()->getUserIntegralRank($uid, [], "");
$userRanking = $userRank['ranking'];
} catch (\Exception $e) {
// 获取用户积分排名异常不影响主流程
\Think\Log::record($e);
}
$integral['ranking'] = $userRanking;
// 初始化返回值
$result = [
'username' => $userInfo['memUsername'],
'dp_name' => $userInfo['dpName'],
'dp_info' => $dpInfo,
'face' => $userInfo['memFace'],
'tag' => isset($tag) ? $tag : [],
'status' => $userInfo['memSubscribeStatus'],
'list' => $list,
'integral' => $integral
];
$this->_result = $result;
}
}