InfoController.class.php
6.56 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<?php
/**
* Created by PhpStorm.
* User: liyifei2012it
* Date: 17/7/26
* Time: 14:08
*/
namespace Apicp\Controller\Customtask;
use Common\Common\Constant;
use Common\Common\Integral;
use Common\Common\TaskHelper;
use Common\Service\CustomtaskService;
use Common\Service\CustomtaskRightService;
use Common\Service\CustomtaskContentService;
class InfoController extends \Apicp\Controller\AbstractController
{
/**
* Info
* @author liyifei
* @desc 常规任务详情接口
* @param Int customtask_id:true 常规任务ID
* @return array
array(
'customtask_id' => 1, // 任务ID
'task_name' => '电商冲击,实体店靠什么赢', // 任务标题
'task_status' => 1, // 任务状态
'start_time' => 1491897290000, // 任务开始时间
'end_time' => 1491897290001, // 任务结束时间
'right' => array( // 新闻阅读权限
'is_all' => 1, // 是否全公司(1=否,2=是)
'tag_list' => array( // 标签
array(
'tag_id' => '3CDBB2867F0000012C7F8D28432943BB', // 标签ID
'tag_name' => 'liyifei001', // 标签名
),
),
'dp_list' => array( // 部门
array(
'dp_id' => 'B65085507F0000017D3965FCB20CA747', // 部门ID
'dp_name' => '一飞冲天', // 部门名
),
),
'user_list' => array( // 人员
array(
'uid' => 'B4B3BA5B7F00000173E870DA6ADFEA2A', // 人员UID
'username' => '缘来素雅', // 姓名
'face' => 'http://shp.qpic.cn/bizmp/gdZUibR6BHrmiar6pZ6pLfRyZSVaXJicn2CsvKRdI9gccXRfP2NrDvJ8A/', // 头像
),
),
'job_list' => array( // 职位
array(
'job_id' => '62C316437F0000017AE8E6ACC7EFAC22', // 职位ID
'job_name' => '攻城狮', // 职位名称
),
),
'role_list' => array( // 角色
array(
'role_id' => '62C354B97F0000017AE8E6AC4FD6F429', // 角色ID
'role_name' => '国家元首', // 角色名称
),
),
),
'description' => '这是一个任务描述', // 任务描述
'content' => array( // 任务内容
array(
'customtask_content_id' => 1, // 任务内容ID
'title' => '公司日常', // 任务内容标题
'app' => 'course', // 所属应用
'content_status' => 1, // 内容状态(1=正常;2=已删除)
'order' => 1, // 排序号
'url' => 'http://dengta.vchangyi.com/123', // 内容详细地址
'exam_type' => 1, // 试卷类型(仅考试应用返回)
'paper_type' => 1, // 试卷使用类型(仅考试应用返回)
),
),
'is_reward' => 1, // 是否发放激励(1=不发放;2=发放)
'reward_setting' => array( // 激励设置(is_reward=1时,此参数值为空字符串)
'type' => 1, // 激励类型(1=勋章;2=积分)
'medal_id' => 'xxx', // 勋章ID
'medal_name' => '荣耀王者', // 勋章名
'integral' => 0, // 积分数
),
'is_notice' => 1, // 运营设置(1=不提醒;2=提醒)
'complete_total' => 30, // 已完成总人数
'process_total' => 30, // 执行中总人数
'unstart_total' => 40, // 未参与总人数
'complete_rate' => 30, // 完成率
'stop_desc' => '我想终止就终止', // 终止原因
'stop_ea_name' => '大侠', // 终止人名称
'stop_mobile' => '15901819173', // 终止人手机号
)
*/
public function Index_post()
{
$customtaskId = I('post.customtask_id', 0, 'intval');
if ($customtaskId == 0) {
E('_ERR_CUSTOMTASK_ID_IS_EMPTY');
}
$taskServ = new CustomtaskService();
$task = $taskServ->get($customtaskId);
if (empty($task)) {
E('_ERR_CUSTOMTASK_NOT_FOUND');
}
// 任务内容
$contentServ = new CustomtaskContentService();
$task['content'] = $contentServ->getData($customtaskId);
// 适用范围
$rightServ = new CustomtaskRightService();
$task['right'] = $rightServ->getData(['customtask_id' => $customtaskId]);
// 激励设置
if ($task['is_reward'] == Constant::CUSTOMTASK_REWARD_OPEN && !empty($task['reward_setting'])) {
$task['reward_setting'] = unserialize($task['reward_setting']);
// 查询勋章名称
if ($task['reward_setting']['type'] == Constant::REWARD_TYPE_MEDAL && !empty($task['reward_setting']['medal_id'])) {
$IntegralServ = &Integral::instance();
$medals = $IntegralServ->listMedal($task['reward_setting']['medal_id']);
$task['reward_setting']['medal_name'] = isset($medals[0]['name']) ? $medals[0]['name'] : '';
}
}
// 任务完成情况
$taskHelper = &TaskHelper::instance();
list(, $uids_complete, $uids_process, $uids_unbegin) = $taskHelper->getCustomtaskUserData($customtaskId);
// 已完成人员列表
$task['complete_total'] = count($uids_complete);
// 执行中人员列表
$task['process_total'] = count($uids_process);
// 未参与人员列表
$task['unstart_total'] = count($uids_unbegin);
// 完成率
$task['complete_rate'] = round($task['complete_total'] / ($task['unstart_total'] + $task['process_total'] + $task['complete_total']) * 100, 2);
$this->_result = $task;
}
}