InfoController.class.php
4.21 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php
/**
* Created by PhpStorm.
* User: liyifei2012it
* Date: 16/9/18
* Time: 11:22
*/
namespace Api\Controller\User;
use Common\Common\Cache;
use Common\Common\Constant;
use Common\Common\Department;
use Common\Model\AttrModel;
use Common\Service\UserService;
use Common\Common\User;
use Common\Common\Integral;
use Common\Common\Teacher;
class InfoController extends AbstractController
{
/**
* 【通讯录】个人详情
* @author liyifei
* @time 2016-09-18 11:32:34
*/
public function Index_post()
{
$uid = I('post.uid', '', 'trim');
if (empty($uid)) {
E('_ERR_UID_IS_NULL');
}
// 是否是"我的"页面顶部展示的个人信息(2017-10-23修改:因"我的"页面顶部用户信息加载过慢,故加该参数判断,省去不必要的信息查询)
$index_show = I('post.index_show', '', 'trim');
// 属性列表
$userService = new UserService();
$attrs = $userService->getAttrList(false, array(), false, false);
$list = $userService->getUserInfoByUid($uid, $attrs);
$list = array_combine_by_key($list, 'field_name');
// 用户信息(从缓存架构用户信息表中的数据获取用户信息,参数设为true越过缓存)
$commUser = new User();
$userInfo = $commUser->getByUid($uid);
// 组织路径 (有部门 并且 员工属性开启了手机端显示)
$departmentPath = '';
if (!empty($userInfo['dpName']) && $list['dpName']['is_show'] == AttrModel::ATTR_IS_SHOW_TRUE) {
$departmentPath = Department::instance()->getCdNames($userInfo['dpName'][0]['dpId']);
// 非"我的"页面顶部展示信息
if (!$index_show) {
// 企业信息
$enterprise = Cache::instance()->get(
'Common.EnterpriseDetail',
'',
['expire' => cfg('ENTERPRISE_DETAIL_CACHE_EXPIRE')]
);
// 写入属性列表数据内
$list['dpName']['attr_value'] = $departmentPath;
}
}
// "我的"页面顶部展示信息
if ($index_show) {
// 初始化返回值
$result = [
// 是否本人
'oneself' => $this->uid == $uid,
'name' => $userInfo['memUsername'],
'title' => $userInfo['memJob'],
'face' => $userInfo['memFace'],
'departmentPath' => $departmentPath
];
} else {
// 初始化返回值
$list = array_values($list);
$result = [
// 是否本人
'oneself' => $this->uid == $uid,
'qy_name' => $enterprise['epName'],
'name' => $userInfo['memUsername'],
'sex' => $userInfo['memGender'],
'title' => $userInfo['memJob'],
'face' => $userInfo['memFace'],
'qr_code' => oaUrl('Frontend/Index/ContactQrcode/index', ['uid' => $uid]),
'departmentPath' => $departmentPath,
'is_custom' => in_array(Constant::AREA_CUSTOM, array_column($list, 'postion')) ?
Constant::CUSTOM_ATTR_YES : Constant::CUSTOM_ATTR_NO,
'list' => $list,
];
}
// 学分
$integralServ = &Integral::instance();
$integralList = $integralServ->listByUid([$uid], 'mi_type1');
$result['credit'] = isset($integralList[$uid]['available']) ? $integralList[$uid]['available'] : 0;
// 积分
$integralList = $integralServ->listByUid([$uid]);
$result['integral'] = isset($integralList[$uid]['available']) ? $integralList[$uid]['available'] : 0;
// 勋章
$result['medal'] = 0;
$medalList = $integralServ->listMedalTotalByUid(['mem_uid' => $uid]);
foreach ($medalList as $medal) {
$result['medal'] += $medal['im_total'];
}
// 是否为讲师
$teacherServ = &Teacher::instance();
$teacher = $teacherServ->getTeacherByConds(['uid' => $uid, 'teacher_status' => 1]);
$result['is_teacher'] = !empty($teacher);
$this->_result = $result;
}
}