Commit 30dc80ac authored by 夏彬's avatar 夏彬

Merge remote-tracking branch 'origin/master'

parents d26312b4 cff91438
...@@ -38,5 +38,8 @@ Message::setDebug(); ...@@ -38,5 +38,8 @@ Message::setDebug();
//$info = \internalApi\ucenter\Message::pushMsg(1,0,0,'bbs','theme',0); //$info = \internalApi\ucenter\Message::pushMsg(1,0,0,'bbs','theme',0);
//print_r($info); //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); print_r($ret);
...@@ -11,4 +11,4 @@ use internalApi\ucenter\Notice; ...@@ -11,4 +11,4 @@ use internalApi\ucenter\Notice;
require __DIR__.'/_init.php'; require __DIR__.'/_init.php';
Notice::setDebug(); Notice::setDebug();
Notice::addToast(12, 'test'); Notice::addToastAsync(12, 'test '.date('Y-m-d H:i:s'));
...@@ -6,13 +6,10 @@ ...@@ -6,13 +6,10 @@
* Time: 11:54 AM * Time: 11:54 AM
*/ */
use internalApi\ucenter\Event;
use internalApi\ucenter\Member; use internalApi\ucenter\Member;
require __DIR__.'/_init.php'; require __DIR__.'/_init.php';
Member::setDebug(true); Event::setDebug();
Event::publish('commission_settlement', time());
$data = Member::getVipByWxhuid('dccc5b52016510003f78525400781c54'); \ No newline at end of file
//$data = User::canAddGoldCoin(13739230723);
print_r($data);
\ No newline at end of file
...@@ -10,4 +10,19 @@ use internalApi\ucenter\Track; ...@@ -10,4 +10,19 @@ use internalApi\ucenter\Track;
require __DIR__.'/_init.php'; 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 ...@@ -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));
}
/** /**
* 对请求进程签名 * 对请求进程签名
* *
......
...@@ -85,6 +85,18 @@ class Thread extends Client ...@@ -85,6 +85,18 @@ class Thread extends Client
return self::call('thread.getThread',compact('fid','page','num')); return self::call('thread.getThread',compact('fid','page','num'));
} }
/**
* 根据帖子标题获取帖子
* @param string $keywords
* @param int $page
* @param int $num
* @return mixed
*/
public static function getThreadByKeywords($keywords = '', $page, $num)
{
return self::call('thread.getThreadByKeywords',compact('keywords','page','num'));
}
/** /**
* 获取板块帖子 * 获取板块帖子
* @param int $bid * @param int $bid
...@@ -104,4 +116,78 @@ class Thread extends Client ...@@ -104,4 +116,78 @@ class Thread extends Client
{ {
return self::call('thread.getDigest',compact('num')); 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'));
}
/**
* 回复评论帖子
* @param $tid
* @param $message
* @param $uid
* @param $pushTime
* @return mixed
*/
public static function setThreadReply($tid, $message, $uid, $pushTime)
{
return self::call('thread.setThreadReply',compact('tid','message','uid', 'pushTime'));
}
/**
* 发布用户动态
*
* @param $message
* @param $uid
* @param $pushTime
* @param $tags
* @return mixed
*/
public static function setDynamic($message, $uid, $pushTime, $tags)
{
return self::call('thread.setDynamic',compact('message','uid', 'pushTime', 'tags'));
}
/**
* 点赞帖子
*
* @param $tid
* @param $uid
* @return mixed
*/
public static function addThreadRecommend($tid, $uid)
{
return self::call('thread.addThreadRecommend',compact('tid','uid'));
}
/**
* 点赞评论
*
* @param $tid
* @param $uid
* @param $postList
* @return mixed
*/
public static function addPostReview($tid, $uid, $postList)
{
return self::call('thread.addPostReview',compact('tid','uid','postList'));
}
/**
* 获取帖子评论列表
*
* @param $tid
* @return mixed
*/
public static function getThreadCommentList($tid)
{
return self::call('thread.getThreadCommentList',compact('tid'));
}
} }
\ No newline at end of file
...@@ -41,5 +41,10 @@ return [ ...@@ -41,5 +41,10 @@ return [
'apiUrl' => 'http://appapi.fecshoptest.com/v1/internalapi', 'apiUrl' => 'http://appapi.fecshoptest.com/v1/internalapi',
'clientId' => 'common', 'clientId' => 'common',
'clientSecret' => 'qlOCFMUfxWjOhK2bdL88e3w2DjdhUDIA' 'clientSecret' => 'qlOCFMUfxWjOhK2bdL88e3w2DjdhUDIA'
] ],
'_async_server' => [
'host' => '172.16.0.181',
'port' => 11300,
'tube' => 'internal-api'
]
]; ];
...@@ -33,8 +33,13 @@ return [ ...@@ -33,8 +33,13 @@ return [
'clientSecret' => '6A23057D233DA902B5D603A758B0438E' 'clientSecret' => '6A23057D233DA902B5D603A758B0438E'
], ],
'shop' => [ 'shop' => [
'apiUrl' => 'http://api-shop.banshouhui.com/internalapi/api', 'apiUrl' => 'http://api-shop.banshouhui.com/v1/internalapi',
'clientId' => 'common', 'clientId' => 'common',
'clientSecret' => 'qlOCFMUfxWjOhK2bdL88e3w2DjdhUDIA' 'clientSecret' => 'qlOCFMUfxWjOhK2bdL88e3w2DjdhUDIA'
] ],
'_async_server' => [
'host' => '127.0.0.1',
'port' => 11301,
'tube' => 'internal-api'
]
]; ];
...@@ -28,7 +28,7 @@ return [ ...@@ -28,7 +28,7 @@ return [
'clientSecret' => 'AJmfi4ORZURS0JwSkdiq3r' 'clientSecret' => 'AJmfi4ORZURS0JwSkdiq3r'
], ],
'shop' => [ 'shop' => [
'apiUrl' => 'http://api-shop.test.yunyamooc.com/internalapi/api', 'apiUrl' => 'http://api-shop.test.yunyamooc.com/v1/internalapi',
'clientId' => 'common', 'clientId' => 'common',
'clientSecret' => 'qlOCFMUfxWjOhK2bdL88e3w2DjdhUDIA' 'clientSecret' => 'qlOCFMUfxWjOhK2bdL88e3w2DjdhUDIA'
], ],
...@@ -36,5 +36,10 @@ return [ ...@@ -36,5 +36,10 @@ return [
'apiUrl' => 'http://sv.test.yunyamooc.com/api/server', 'apiUrl' => 'http://sv.test.yunyamooc.com/api/server',
'clientId' => 'common', 'clientId' => 'common',
'clientSecret' => '6A23057D233DA902B5D603A758B0438E' 'clientSecret' => '6A23057D233DA902B5D603A758B0438E'
],
'_async_server' => [
'host' => '127.0.0.1',
'port' => 11300,
'tube' => 'internal-api'
] ]
]; ];
<?php
/**
* Created by PhpStorm.
* User: pader
* Date: 2019/5/29
* Time: 14:42
*/
namespace internalApi\ucenter;
use internalApi\base\ApiException;
use internalApi\base\Client;
use internalApi\base\ClientException;
class Event extends Client
{
/**
* 用于第三方调用的远程事件发布
*
* @param string $event
* @param int $time
* @param mixed $data
* @throws ApiException|ClientException
*/
public static function publish($event, $time, $data=null)
{
self::call('event.publish', compact('event', 'time', 'data'));
}
}
\ No newline at end of file
...@@ -15,21 +15,105 @@ use internalApi\base\Client; ...@@ -15,21 +15,105 @@ use internalApi\base\Client;
class Label extends Client class Label extends Client
{ {
//类型 1=>认证 2=>品类 3=>品牌 4=>热门事件 5=>现象 6=>故障点 7=>专题
const TYPE_AUTH = 1; // 认证
const TYPE_CATEGORY = 2; // 品类
const TYPE_BRAND = 3; // 品牌
const TYPE_HOT_EVENTS = 4; // 热门事件
const TYPE_PHENOMENON = 5; // 现象
const TYPE_FAULT = 6; // 故障点
const TYPE_SPECIAL_TOPIC = 7; // 专题
//类型 1=>认证 2=>品类 3=>品牌 // 1=>thread 2=>moment 3=>course 4=>section
const TYPE_AUTH = 1; //认证 const FROM_THREAD = 1;
const TYPE_CATEGORY = 2; //品类 const FROM_MOMENT = 2;
const TYPE_BRAND = 3; //品牌 const FROM_COURSE = 3;
const FROM_SECTION = 4;
/**
* @param array/int $type 1=>认证 2=>品类 3=>品牌 /**
* @return mixed * @param array/int $type 1=>认证 2=>品类 3=>品牌
* @throws \internalApi\base\ApiException *
* @throws \internalApi\base\ClientException * @return mixed
*/ * @throws \internalApi\base\ApiException
public static function getLabels($type = null) * @throws \internalApi\base\ClientException
{ */
return self::call('label.getLabels', compact('type')); public static function getLabels($type = null){
} return self::call('label.getLabels', compact('type'));
}
/**
* 标签分类
*
* @param array $labels 标签
* @param array $types //类型 1=>认证 2=>品类 3=>品牌 4=>热门事件 5=>现象 6=>故障点 7=>专题
*
* @return array
* @throws \internalApi\base\ApiException
* @throws \internalApi\base\ClientException
*/
public static function getListByLabels($labels, $types = [self::TYPE_CATEGORY, self::TYPE_BRAND, self::TYPE_PHENOMENON, self::TYPE_FAULT]){
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'));
}
} }
...@@ -26,7 +26,7 @@ class Member extends Client ...@@ -26,7 +26,7 @@ class Member extends Client
* other 其它信息 * other 其它信息
* verify 基本认证信息,例如姓名、地区等 * verify 基本认证信息,例如姓名、地区等
* 如指定 ['basic', 'vip'] 即代表取基本信息与服务星等级信息 * 如指定 ['basic', 'vip'] 即代表取基本信息与服务星等级信息
* 当指定 vip 时,如 vip_grade 字段返回值为 -1 则代表该成员只是准服务星,还需完善资料。 * 当指定 vip 时,返回 vip_complete 表示是否完善资料。
* @return array|null * @return array|null
* @throws \internalApi\base\ApiException * @throws \internalApi\base\ApiException
* @throws \internalApi\base\ClientException * @throws \internalApi\base\ClientException
......
...@@ -66,6 +66,20 @@ class Message extends Client ...@@ -66,6 +66,20 @@ class Message extends Client
return self::call('message.sendTemplateSms', compact('tel', 'templateId', 'templateParams', 'signature')); 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 ...@@ -80,87 +94,19 @@ class Message extends Client
return self::call('message.sendTemplateSmsByUid', compact('uid', 'templateId', 'templateParams', 'signature')); return self::call('message.sendTemplateSmsByUid', compact('uid', 'templateId', 'templateParams', 'signature'));
} }
/*** /**
* @param $userId * 向指定用户发送模板短信
* @param $title *
* @param $sourceUrl * @param int $uid
* @param $from 0:xue 1:bbs 2:s * @param string $templateId 内部短信模板ID
* @param $type 0:评论 1:帖子 * @param array $templateParams 短信模板变量内容
* @param $commentId * @param string $signature 短信签名
* @param $replyUserId * @return int|false
* @param string $replyedComment */
* @param string $extra public static function sendTemplateSmsByUidAsync($uid, $templateId, $templateParams=[], $signature=null)
* @return mixed {
* @deprecated return self::emit('message.sendTemplateSmsByUid', func_get_args());
*/ }
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)
{}
/** /**
* 以系统会话发送消息 * 以系统会话发送消息
...@@ -172,6 +118,7 @@ class Message extends Client ...@@ -172,6 +118,7 @@ class Message extends Client
* @param array $content 消息内容 * @param array $content 消息内容
* @param array $ext 消息扩展属性 * @param array $ext 消息扩展属性
* @return array * @return array
* @see http://dzzoffice.banshouhui.com/index.php?mod=corpus&op=list&cid=3#fid_1146
* @throws \internalApi\base\ApiException * @throws \internalApi\base\ApiException
*/ */
public static function sendSystemMessage($systemSessionId, $from, $to, $type, $content, $ext=[]) public static function sendSystemMessage($systemSessionId, $from, $to, $type, $content, $ext=[])
...@@ -179,5 +126,22 @@ class Message extends Client ...@@ -179,5 +126,22 @@ class Message extends Client
return self::call('message.sendSystemMessage', compact('systemSessionId', 'from', 'to', 'type', 'content', 'ext')); 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 ...@@ -55,4 +55,46 @@ class Notice extends Client
self::call('notice.addToast', compact('uid', 'text', 'timeout')); 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 ...@@ -31,6 +31,20 @@ class Track extends Client
return self::call('track.track', compact('event', 'uid', 'time', 'props')); 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