Commit 02121869 authored by 陈国太's avatar 陈国太

Merge remote-tracking branch 'origin/master'

parents 94c766e0 5622131a
......@@ -38,5 +38,8 @@ Message::setDebug();
//$info = \internalApi\ucenter\Message::pushMsg(1,0,0,'bbs','theme',0);
//print_r($info);
$ret = Message::sendSystemMessage('assistant', 0, 12, Message::TYPE_TEXT, ['msg'=>'新消息测试']);
$ret = Message::sendSystemMessageAsync('remind', 0, 12, Message::TYPE_REMIND, [
'title' => '测试的标题',
'text'=>'新消息测试'.uniqid()
]);
print_r($ret);
......@@ -11,4 +11,4 @@ use internalApi\ucenter\Notice;
require __DIR__.'/_init.php';
Notice::setDebug();
Notice::addToast(12, 'test');
Notice::addToastAsync(12, 'test '.date('Y-m-d H:i:s'));
......@@ -6,13 +6,10 @@
* Time: 11:54 AM
*/
use internalApi\ucenter\Event;
use internalApi\ucenter\Member;
require __DIR__.'/_init.php';
Member::setDebug(true);
$data = Member::getVipByWxhuid('dccc5b52016510003f78525400781c54');
//$data = User::canAddGoldCoin(13739230723);
print_r($data);
\ No newline at end of file
Event::setDebug();
Event::publish('commission_settlement', time());
\ No newline at end of file
......@@ -10,4 +10,19 @@ use internalApi\ucenter\Track;
require __DIR__.'/_init.php';
echo Track::track('test');
//echo Track::track('test');
$ret = Track::trackAsync('_view', 12, time(), [
'内容标题' => '这是一个测试你懂的',
'内容ID' => '123',
'内容类型' => '帖子',
'_id' => '123',
'_title' => '这是一个测试你懂的',
'_type' => 'post',
'_author' => 12,
'_visitor' => uniqid(),
'_reflow' => 1
]);
print_r($ret);
echo "\n";
This diff is collapsed.
......@@ -137,6 +137,70 @@ class Client
}
}
/**
* 向消息队列添加一个异步调用请求
*
* @param string $api
* @param array $params 参数列表,注意此参数列表与 call() 中的参数列表完全不同,此参数列表为纯数组形式(数字键名),
* 且参数顺序须与被调用服务顺序完全一致
* @see call
* @return int|boolean 入队列成功则返回消息ID,失败返回false
*/
protected static function emit($api, $params=[])
{
static $client = null;
if ($client === null) {
$config = self::$config['_async_server'];
$client = new Beanstalk([
'host' => $config['host'],
'port' => $config['port']
]);
$client->connect();
$client->useTube($config['tube']);
}
$msg = [
'target' => self::name(),
'api' => $api,
'params' => $params,
'time' => time(),
'nonce' => uniqid(),
'ver' => 0
];
$ext = [];
//添加客户端信息以辨服务端识别和调试
$userAgent = 'PHP/'.PHP_VERSION.' ('.PHP_OS.') Client/beanstalk';
if (isset($_SERVER['HTTP_HOST'])) {
$userAgent .= ' ('.$_SERVER['HTTP_HOST'].')';
}
$ext['ua'] = $userAgent;
//IP 透传
if (isset($_SERVER['REMOTE_ADDR'])) {
$clientIp = !empty($_SERVER['HTTP_CLIENT_IP']) ? $_SERVER['HTTP_CLIENT_IP'] : $_SERVER['REMOTE_ADDR'];
$ext['ip'] = $clientIp;
$forwardedFor = !empty($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] :
($_SERVER['REMOTE_ADDR'] != $_SERVER['SERVER_ADDR'] ? $_SERVER['REMOTE_ADDR'] : '');
if ($forwardedFor && $forwardedFor != $clientIp) {
$forwardedFor .= ','.$_SERVER['SERVER_ADDR'];
$ext['fw'] = $forwardedFor;
}
}
$ext && $msg['ext'] = $ext;
return $client->put(1024, 0, 60, json_encode($msg, JSON_UNESCAPED_UNICODE));
}
/**
* 对请求进程签名
*
......
......@@ -104,4 +104,15 @@ class Thread extends Client
{
return self::call('thread.getDigest',compact('num'));
}
/**
* 根据帖子ID串获取用户是否回答
* @param array $threadArr
* @param int $userId
* @return array
*/
public static function IsAnswerByThreadIds($threadArr, $userId)
{
return self::call('thread.IsAnswerByThreadIds', compact('threadArr', 'userId'));
}
}
\ No newline at end of file
......@@ -41,5 +41,10 @@ return [
'apiUrl' => 'http://appapi.fecshoptest.com/v1/internalapi',
'clientId' => 'common',
'clientSecret' => 'qlOCFMUfxWjOhK2bdL88e3w2DjdhUDIA'
]
],
'_async_server' => [
'host' => '172.16.0.181',
'port' => 11300,
'tube' => 'internal-api'
]
];
......@@ -33,8 +33,13 @@ return [
'clientSecret' => '6A23057D233DA902B5D603A758B0438E'
],
'shop' => [
'apiUrl' => 'http://api-shop.banshouhui.com/internalapi/api',
'apiUrl' => 'http://api-shop.banshouhui.com/v1/internalapi',
'clientId' => 'common',
'clientSecret' => 'qlOCFMUfxWjOhK2bdL88e3w2DjdhUDIA'
]
],
'_async_server' => [
'host' => '127.0.0.1',
'port' => 11301,
'tube' => 'internal-api'
]
];
......@@ -28,7 +28,7 @@ return [
'clientSecret' => 'AJmfi4ORZURS0JwSkdiq3r'
],
'shop' => [
'apiUrl' => 'http://api-shop.test.yunyamooc.com/internalapi/api',
'apiUrl' => 'http://api-shop.test.yunyamooc.com/v1/internalapi',
'clientId' => 'common',
'clientSecret' => 'qlOCFMUfxWjOhK2bdL88e3w2DjdhUDIA'
],
......@@ -36,5 +36,10 @@ return [
'apiUrl' => 'http://sv.test.yunyamooc.com/api/server',
'clientId' => 'common',
'clientSecret' => '6A23057D233DA902B5D603A758B0438E'
],
'_async_server' => [
'host' => '127.0.0.1',
'port' => 11300,
'tube' => 'internal-api'
]
];
......@@ -24,6 +24,12 @@ class Label extends Client
const TYPE_FAULT = 6; // 故障点
const TYPE_SPECIAL_TOPIC = 7; // 专题
// 1=>thread 2=>moment 3=>course 4=>section
const FROM_THREAD = 1;
const FROM_MOMENT = 2;
const FROM_COURSE = 3;
const FROM_SECTION = 4;
/**
* @param array/int $type 1=>认证 2=>品类 3=>品牌
*
......@@ -49,4 +55,65 @@ class Label extends Client
return self::call('label.getListByLabels', compact('labels', 'types'));
}
/**
* 设置话题置顶
*
* @param int $sid 标记id
* @param array $labelIds 话题id数组
* @param int $endTime 截止时间
* @param string $name 标记名称
* @param int $uid 用户中心uid
* @param int $from 来源
*
* @throws \internalApi\base\ApiException
* @throws \internalApi\base\ClientException
*/
public static function setTopicRoof($sid, $labelIds, $endTime = 0, $name = '', $uid = 0, $from = self::FROM_THREAD) {
return self::call('label.setTopicRoof', compact('sid', 'labelIds', 'endTime', 'name', 'uid', 'from'));
}
/**
* 设置话题置顶标记名称
*
* @param int $sid 标记id
* @param string $name 标记名称
* @param int $uid 用户中心uid
* @param int $from 来源
*
* @throws \internalApi\base\ApiException
* @throws \internalApi\base\ClientException
*/
public static function setRoofNameBySid($sid, $name = '', $uid = 0, $from = self::FROM_THREAD)
{
return self::call('label.setRoofNameBySid', compact('sid','name', 'uid', 'from'));
}
/**
* 根据标记id话题置顶数据
*
* @param int $sid 标记id
* @param array $types 标签类型
* @param int $from 来源
*
* @throws \internalApi\base\ApiException
* @throws \internalApi\base\ClientException
*/
public static function getLabelListBySid($sid, $types = [], $from = self::FROM_THREAD) {
return self::call('label.getLabelListBySid', compact('sid', 'types', 'from'));
}
/**
* 获取我的兴趣标签列表
* @param $uid 用户id
*
* @throws \internalApi\base\ApiException
* @throws \internalApi\base\ClientException
*/
public static function getMyInterestList($uid) {
return self::call('label.getMyInterestList', compact('uid'));
}
}
......@@ -66,6 +66,20 @@ class Message extends Client
return self::call('message.sendTemplateSms', compact('tel', 'templateId', 'templateParams', 'signature'));
}
/**
* 向指定手机号发送模板短信
*
* @param string|array $tel 单个或多个号码数组
* @param string $templateId 内部短信模板ID
* @param array $templateParams 短信模板变量内容
* @param string $signature 短信签名
* @return int|false
*/
public static function sendTemplateSmsAsync($tel, $templateId, $templateParams=[], $signature=null)
{
return self::emit('message.sendTemplateSms', func_get_args());
}
/**
* 向指定用户发送模板短信
*
......@@ -80,87 +94,19 @@ class Message extends Client
return self::call('message.sendTemplateSmsByUid', compact('uid', 'templateId', 'templateParams', 'signature'));
}
/***
* @param $userId
* @param $title
* @param $sourceUrl
* @param $from 0:xue 1:bbs 2:s
* @param $type 0:评论 1:帖子
* @param $commentId
* @param $replyUserId
* @param string $replyedComment
* @param string $extra
* @return mixed
* @deprecated
*/
public static function addComment($userId, $title, $sourceUrl, $from, $type, $commentId, $replyUserId, $replyedComment = '', $extra = '')
{}
/**
* @param $userId
* @param $title
* @param $sourceUrl
* @param $from
* @param $type
* @param $sourceId 点赞的评论id
* @param $likeUserId
* @param $likedComment
* @return mixed
* @deprecated
*/
public static function addLike($userId, $title, $sourceUrl, $from, $type, $sourceId, $likeUserId, $likedComment = '')
{}
/**
* @param $userId
* @param $title
* @param $desc
* @param $from
* @param $type
* @param string $content
* @param int $toUser 0系统消息其它为用户id,多个用户id数组
* @return mixed
* @deprecated
*/
public static function add($userId, $title, $desc, $from, $type, $content = '', $toUser = 0)
{}
/**
* 删除评论消息
* @param $userId
* @param $from
* @param $type
* @param $commentId
* @return mixed
* @deprecated
*/
public static function deleteComment($userId, $from, $type, $commentId)
{}
/**
* 删除点赞
* @param $userId
* @param $from
* @param $type
* @param $sourceId
* @return mixed
* @deprecated
*/
public static function deleteLiked($userId, $from, $type, $sourceId)
{}
/**
* @param $title 消息标题
* @param $url
* @param $desc 描述
* @param int $userId 用户id 0=>代表全部
* @param string $from 来自
* @param int $type 0 早报 1 求助 2 系统推送
* @return mixed
* @deprecated
*/
public static function pushMsg($title, $url, $desc, $userId = 0, $from = 'u', $type = 0)
{}
/**
* 向指定用户发送模板短信
*
* @param int $uid
* @param string $templateId 内部短信模板ID
* @param array $templateParams 短信模板变量内容
* @param string $signature 短信签名
* @return int|false
*/
public static function sendTemplateSmsByUidAsync($uid, $templateId, $templateParams=[], $signature=null)
{
return self::emit('message.sendTemplateSmsByUid', func_get_args());
}
/**
* 以系统会话发送消息
......@@ -172,6 +118,7 @@ class Message extends Client
* @param array $content 消息内容
* @param array $ext 消息扩展属性
* @return array
* @see http://dzzoffice.banshouhui.com/index.php?mod=corpus&op=list&cid=3#fid_1146
* @throws \internalApi\base\ApiException
*/
public static function sendSystemMessage($systemSessionId, $from, $to, $type, $content, $ext=[])
......@@ -179,5 +126,22 @@ class Message extends Client
return self::call('message.sendSystemMessage', compact('systemSessionId', 'from', 'to', 'type', 'content', 'ext'));
}
/**
* 以系统会话发送消息
*
* @param int|string $systemSessionId 系统会话的ID或别名
* @param int $from 发送用户,系统用户请指定0
* @param int $to 接收用户
* @param int $type 消息类型
* @param array $content 消息内容
* @param array $ext 消息扩展属性
* @return int|false
* @see http://dzzoffice.banshouhui.com/index.php?mod=corpus&op=list&cid=3#fid_1146
*/
public static function sendSystemMessageAsync($systemSessionId, $from, $to, $type, $content, $ext=[])
{
return self::emit('message.sendSystemMessage', func_get_args());
}
}
......@@ -55,4 +55,46 @@ class Notice extends Client
self::call('notice.addToast', compact('uid', 'text', 'timeout'));
}
/**
* 添加积分提示
*
* @param int $uid
* @param string $action 动作文字,如“发表帖子”
* @param array $credits 变化积分数字,以积分序号对应数字的形式
* @return int|false
*/
public static function addCreditAsync($uid, $action, $credits)
{
return self::emit('notice.addCredit', func_get_args());
}
/**
* 添加勋章提示
*
* @param int $uid
* @param string $icon
* @param string $name
* @param string $description
* @param $url
* @return int|false
*/
public static function addMedalAsync($uid, $icon, $name, $description, $url)
{
return self::emit('notice.addMedal', func_get_args());
}
/**
* 添加Toast提示
*
* @param int $uid
* @param string $text
* @param null|int $timeout 提示留存时间,毫秒单位,默认为 1500
* @return int|false
*/
public static function addToastAsync($uid, $text, $timeout=null)
{
return self::emit('notice.addToast', func_get_args());
}
}
\ No newline at end of file
......@@ -31,6 +31,20 @@ class Track extends Client
return self::call('track.track', compact('event', 'uid', 'time', 'props'));
}
/**
* 添加事件
*
* @param string $event 事件、32个字符以内
* @param int $uid 用户UID,0代表访客
* @param int|null $time 时间,默认为当前时间
* @param array $props 属性键值列表 (键32个字符以内,值128字符以内)
* @return int|false
*/
public static function trackAsync($event, $uid=0, $time=null, $props=[])
{
return self::emit('track.track', func_get_args());
}
/**
* 更新事件
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment