ProcessListController.class.php
2.85 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
<?php
/**
* Created by PhpStorm.
* User: liyifei2012it
* Date: 17/7/26
* Time: 14:08
*/
namespace Api\Controller\Customtask;
use Common\Common\Constant;
use Common\Service\CustomtaskRightService;
use Common\Service\CustomtaskService;
use Common\Service\UserTaskService;
class ProcessListController extends \Api\Controller\AbstractController
{
/**
* ProcessList
* @author tangxingguo
* @desc 进行中常规任务列表接口
* @return array
array(
'complete_task' => 100, // 已完成任务总数
'list' => array(
'customtask_id' => 1, // 任务ID
'task_name' => '艰难的任务', // 任务名称
'progress' => 80, // 任务完成百分比
'start_time' => 1501724335242, // 任务最后更新时间
),
);
*/
public function Index_post()
{
$user = $this->_login->user;
// 未完成的常规任务
$userTaskServ = new UserTaskService();
$myTasks = $userTaskServ->list_by_conds([
'uid' => $this->uid,
'complete_status' => Constant::USER_TASK_COMPLETE_STATUS_PROCESS,
'task_status' => Constant::CUSTOMTASK_STATUS_PROCESS
]);
$list = [];
if (!empty($myTasks)) {
// 取常规任务信息
$totalTaskId = array_column($myTasks, 'customtask_id');
// 过滤无权限的任务
$rightServ = new CustomtaskRightService();
$right = $rightServ->getUserRight($user);
$taskIdArr = $rightServ->idByRight($right, $totalTaskId);
$taskIds = array_column($taskIdArr, 'customtask_id');
// 根据id获取任务信息
$taskServ = new CustomtaskService();
$order_option = ['start_time' => 'DESC', 'send_time' => 'DESC'];
$taskList = $taskServ->list_by_conds(['customtask_id' => $taskIds], null, $order_option);
// 组合数据
$myTasks = array_combine_by_key($myTasks, 'customtask_id');
foreach ($taskList as $v) {
$list[] = [
'customtask_id' => $v['customtask_id'],
'task_name' => $v['task_name'],
'progress' => $myTasks[$v['customtask_id']]['progress'],
'complete_total' => $v['complete_total'],
'end_time' => $v['end_time'],
];
}
}
// 已完成常规任务总数
$totalComplete = $userTaskServ->count_by_conds([
'uid' => $this->uid,
'complete_status' => Constant::USER_TASK_COMPLETE_STATUS_COMPLETE,
]);
$this->_result = [
'complete_task' => $totalComplete,
'list' => $list,
];
}
}