This commit is contained in:
lisida 2019-02-25 11:27:28 +08:00
parent a155f52333
commit 338e38825b
3 changed files with 641 additions and 173 deletions

View File

@ -12,12 +12,17 @@
]
},
"require": {
"arch/php-internal-api-client": "^0.6.1"
"arch/php-internal-api-client": "^0.6.1",
"paidian/json-rpc": "~1.1"
},
"repositories": {
"php-internal-api-client": {
"type": "vcs",
"url": "git@git.int.haowumc.com:arch/php-internal-api-client.git"
},
"php-json-rpc": {
"type": "vcs",
"url": "git@git.int.haowumc.com:composer/php-json-rpc.git"
}
}
}

673
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,12 @@
<?php
define('CRM_API_CONFIG', [
'base_uri' => 'http://push.in.haowumc.com/api/wechat/',
'appid' => 'notification',
'secret' => '123456',
define('RPC_CONFIG',[
'app' => env('APP_NAME'),
'client' => [
'auth' => [
'base_uri' => 'http://auth.in.haowumc.com',
],
],
]);
/**
@ -15,12 +18,13 @@ define('CRM_API_CONFIG', [
function chat_text_alert($chat, $text)
{
$client = new \PdInternalApi\Client('crm', CRM_API_CONFIG);
$base_client = new \JsonRpc\Client(RPC_CONFIG);
$client = $base_client->endpoint('auth');
try {
$resp = $client->call('work/text', [
'chat_id' => $chat,
'text' => $text,
$resp = $client->call('notify.text', [
['chat' => $chat],
$text,
]);
} catch (Exception $ex) {
var_dump($ex->getMessage());
@ -32,26 +36,26 @@ function chat_text_alert($chat, $text)
/**
* 对单个或多个用户发送报警或通知信息多个用户id使用 | 隔开
* @param $username
* @param $text
* @return mixed|null
*/
function user_text_alert($username, $text)
{
$base_client = new \JsonRpc\Client(RPC_CONFIG);
$client = $base_client->endpoint('auth');
$client = new \PdInternalApi\Client('crm', CRM_API_CONFIG);
$username = explode('|',$username);
try {
$resp = $client->call('work/text', [
'username' => $username,
'text' => $text,
$res = $client->call('notify.text', [
['user' => $username],
$text,
]);
} catch (Exception $ex) {
var_dump($ex->getMessage());
return null;
}
return $resp;
return $res;
}
/**
@ -65,16 +69,16 @@ function user_text_alert($username, $text)
*/
function chat_card_alert($chat, $title, $desc, $button, $url)
{
$client = new \PdInternalApi\Client('crm', CRM_API_CONFIG);
$base_client = new \JsonRpc\Client(RPC_CONFIG);
$client = $base_client->endpoint('auth');
try {
$resp = $client->call('work/card', [
'chat_id' => $chat,
'title' => $title,
'desc' => $desc,
'button' => $button,
'url' => $url,
$resp = $client->call('notify.card', [
['chat' => $chat],
$title,
$desc,
$button,
$url,
]);
} catch (Exception $ex) {
var_dump($ex->getMessage());
@ -95,16 +99,86 @@ function chat_card_alert($chat, $title, $desc, $button, $url)
*/
function user_card_alert($username, $title, $desc, $button, $url)
{
$base_client = new \JsonRpc\Client(RPC_CONFIG);
$client = $base_client->endpoint('auth');
$client = new \PdInternalApi\Client('crm', CRM_API_CONFIG);
$username = explode('|',$username);
try {
$resp = $client->call('notify.card', [
['user' => $username],
$title,
$desc,
$button,
$url,
]);
} catch (Exception $ex) {
var_dump($ex->getMessage());
return null;
}
return $resp;
}
/**
* 对单个或多个用户发送文本卡片多个用户id使用 | 隔开
* @param $username
* @param $appid //小程序的appid
* @param $title //标题
* @param $page //小程序页面路径
* @param $desc //描述
* @param $items //消息内容键值对最多允许10个item
* @param $emphasisFirstItem //是否放大第一个content_item
* @return mixed|null
*/
function user_mp_alert($username, $appid, $title, $page = null, $desc = null,$items = null,$emphasisFirstItem = null)
{
$base_client = new \JsonRpc\Client(RPC_CONFIG);
$client = $base_client->endpoint('auth');
$username = explode('|',$username);
try {
$resp = $client->call('notify.mp', [
['user' => $username],
$appid,
$title,
$page,
$desc,
$items,
$emphasisFirstItem
]);
} catch (Exception $ex) {
var_dump($ex->getMessage());
return null;
}
return $resp;
}
/**
* 对单个或多个用户发送文本卡片多个用户id使用 | 隔开
* @param $username
* @param $appid //小程序的appid
* @param $title //标题
* @param $page //小程序页面路径
* @param $desc //描述
* @param $items //消息内容键值对最多允许10个item
* @param $emphasisFirstItem //是否放大第一个content_item
* @return mixed|null
*/
function tag_mp_alert($tag, $appid, $title, $page = null, $desc = null,$items = null,$emphasisFirstItem = null)
{
$base_client = new \JsonRpc\Client(RPC_CONFIG);
$client = $base_client->endpoint('auth');
try {
$resp = $client->call('work/card', [
'username' => $username,
'title' => $title,
'desc' => $desc,
'button' => $button,
'url' => $url,
$resp = $client->call('notify.mp', [
['tag' => $tag],
$appid,
$title,
$page,
$desc,
$items,
$emphasisFirstItem
]);
} catch (Exception $ex) {
var_dump($ex->getMessage());