SendNewCustomtaskMsgController.class.php
1.74 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
<?php
/**
* Created by PhpStorm.
* User: zhonglei
* Date: 17/8/22
* Time: 14:13
*/
namespace Frontend\Controller\Callback;
use Think\Log;
use Common\Common\Constant;
use Common\Common\TaskHelper;
use Common\Service\CustomtaskService;
class SendNewCustomtaskMsgController extends AbstractController
{
/**
* 定时发送新常规任务消息回调接口
* @author zhonglei
*/
public function Index()
{
$stream_data = file_get_contents('php://input');
$stream_data = empty($stream_data) ? [] : json_decode($stream_data, true);
Log::record('---SendNewCustomtaskMsg stream data:' . var_export($stream_data, true), Log::INFO);
$customtask_id = I('get.customtask_id', 0, 'intval');
$uids = isset($stream_data['uids']) ? $stream_data['uids'] : [];
$this->_sendMsg($customtask_id, $uids);
exit('SUCCESS');
}
/**
* 发送消息
* @author zhonglei
* @param int $customtask_id 常规任务ID
* @param array $uids 用户ID数组
* @return bool
*/
private function _sendMsg($customtask_id, $uids)
{
if (empty($customtask_id) || !is_array($uids) || empty($uids)) {
Log::record('not found customtask_id or uids');
return false;
}
$customtaskServ = new CustomtaskService();
$customtask = $customtaskServ->get_by_conds([
'customtask_id' => $customtask_id,
'task_status' => Constant::CUSTOMTASK_STATUS_PROCESS,
]);
if (empty($customtask)) {
Log::record('not found customtask');
return false;
}
$taskHelper = &TaskHelper::instance();
$taskHelper->sendNewCustomtaskMsg($customtask, $uids);
return true;
}
}