UpdateTotalController.class.php
1.55 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
<?php
/**
* Created by PhpStorm.
* User: zhonglei
* Date: 17/7/25
* Time: 11:57
*/
namespace Apicp\Controller\Customtask;
use Common\Common\Constant;
use Common\Common\TaskHelper;
use Common\Service\CustomtaskService;
class UpdateTotalController extends \Apicp\Controller\AbstractController
{
/**
* UpdateTotal
* @author zhonglei
* @desc 更新常规任务参与人数、已完成人数接口(已结束、已终止任务将不会更新)
* @param Array customtask_ids:true 常规任务ID数组
* @return array
*/
public function Index_post()
{
$customtask_ids = I('post.customtask_ids', []);
if (!is_array($customtask_ids) || empty($customtask_ids)) {
E('_ERR_CUSTOMTASK_IDS_INVALID');
}
$conds = [
'customtask_id' => $customtask_ids,
'task_status < ?' => Constant::CUSTOMTASK_STATUS_END,
'count_time <= ?' => MILLI_TIME - Constant::CUSTOMTASK_REFRESH_TIME,
];
$taskHelper = &TaskHelper::instance();
$taskServ = new CustomtaskService();
$task_list = $taskServ->list_by_conds($conds);
foreach ($task_list as $customtask) {
list($uids_all, $uids_complete) = $taskHelper->getCustomtaskUserData($customtask['customtask_id']);
$data = [
'user_total' => count($uids_all),
'complete_total' => count($uids_complete),
'count_time' => MILLI_TIME,
];
$taskServ->update($customtask['customtask_id'], $data);
}
}
}