You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace app\admin\service;
|
|
|
|
|
|
|
|
use GatewayClient\Gateway;
|
|
|
|
require_once __DIR__ . '/../../../vendor/autoload.php';
|
|
|
|
|
|
|
|
class NoticeService extends AdminBaseService
|
|
|
|
{
|
|
|
|
public function popUp($param)
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
if (empty($param['user_ids']) || empty($param['content'])) {
|
|
|
|
return $this->toData('400', '参数错误');
|
|
|
|
}
|
|
|
|
if (!is_string($param['content'])) {
|
|
|
|
return $this->toData('400', 'content参数必须为string类型');
|
|
|
|
}
|
|
|
|
// 多个用户ID之间用英文逗号隔开的
|
|
|
|
if (!is_array($param['user_ids'])) {
|
|
|
|
return $this->toData('400', 'user_ids参数格式错误');
|
|
|
|
}
|
|
|
|
// 循环向每个用户发送弹窗
|
|
|
|
$data = ['type'=>'admin-popup', 'content'=>$param['content']];
|
|
|
|
Gateway::$registerAddress = env('GATEWAY_SERVER.REGISTER');
|
|
|
|
foreach ($param['user_ids'] as $uid) {
|
|
|
|
Gateway::sendToUid($uid, json_encode($data));
|
|
|
|
}
|
|
|
|
return $this->toData('0', 'ok');
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
return $this->toData('500', 'The system error', [$e->getMessage(), $e->getTrace()]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|