SendNoticeController.class.php
1.39 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: 18/4/26
* Time: 15:50
*/
namespace Frontend\Controller\Callback;
use Think\Log;
use VcySDK\Cron;
use VcySDK\Service;
use Common\Common\Constant;
use Common\Common\MapHelper;
use Common\Service\MapService;
class SendNoticeController 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('---SendNotice stream data:' . var_export($stream_data, true), Log::INFO);
$cron_id = I('get.cron_id', '', 'trim');
$map_id = I('get.map_id', 0, 'intval');
$uids = $stream_data['uids'] ?? [];
// 删除计划任务
if (!empty($cron_id)) {
$cronSdk = new Cron(Service::instance());
$cronSdk->delete($cron_id);
}
// 发送消息
if (!empty($map_id) && \is_array($uids) && !empty($uids)) {
$mapServ = new MapService();
$map = $mapServ->get_by_conds(['map_id' => $map_id, 'map_status' => Constant::MAP_STATUS_PUBLISH]);
if (!empty($map)) {
$mapHelper = &MapHelper::instance();
$mapHelper->sendNotice($map, $uids);
}
}
exit('SUCCESS');
}
}