Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
wxh_internal_api
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
杨培培
wxh_internal_api
Commits
02121869
Commit
02121869
authored
Jul 22, 2019
by
陈国太
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
94c766e0
5622131a
Changes
14
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
957 additions
and
94 deletions
+957
-94
ucenter_message.php
example/ucenter_message.php
+4
-1
ucenter_notice.php
example/ucenter_notice.php
+1
-1
ucenter_test.php
example/ucenter_test.php
+3
-6
ucenter_track.php
example/ucenter_track.php
+16
-1
Beanstalk.php
src/base/Beanstalk.php
+671
-0
Client.php
src/base/Client.php
+64
-0
Thread.php
src/bbs/Thread.php
+11
-0
client_config_dev.php
src/client_config_dev.php
+6
-1
client_config_prod.php
src/client_config_prod.php
+7
-2
client_config_test.php
src/client_config_test.php
+6
-1
Label.php
src/ucenter/Label.php
+67
-0
Message.php
src/ucenter/Message.php
+45
-81
Notice.php
src/ucenter/Notice.php
+42
-0
Track.php
src/ucenter/Track.php
+14
-0
No files found.
example/ucenter_message.php
View file @
02121869
...
@@ -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
);
example/ucenter_notice.php
View file @
02121869
...
@@ -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
::
addToast
Async
(
12
,
'test '
.
date
(
'Y-m-d H:i:s'
)
);
example/ucenter_test.php
View file @
02121869
...
@@ -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
example/ucenter_track.php
View file @
02121869
...
@@ -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
"
;
src/base/Beanstalk.php
0 → 100644
View file @
02121869
This diff is collapsed.
Click to expand it.
src/base/Client.php
View file @
02121869
...
@@ -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
));
}
/**
/**
* 对请求进程签名
* 对请求进程签名
*
*
...
...
src/bbs/Thread.php
View file @
02121869
...
@@ -104,4 +104,15 @@ class Thread extends Client
...
@@ -104,4 +104,15 @@ 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'
));
}
}
}
\ No newline at end of file
src/client_config_dev.php
View file @
02121869
...
@@ -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'
]
];
];
src/client_config_prod.php
View file @
02121869
...
@@ -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/internal
api'
,
'clientId'
=>
'common'
,
'clientId'
=>
'common'
,
'clientSecret'
=>
'qlOCFMUfxWjOhK2bdL88e3w2DjdhUDIA'
'clientSecret'
=>
'qlOCFMUfxWjOhK2bdL88e3w2DjdhUDIA'
]
],
'_async_server'
=>
[
'host'
=>
'127.0.0.1'
,
'port'
=>
11301
,
'tube'
=>
'internal-api'
]
];
];
src/client_config_test.php
View file @
02121869
...
@@ -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/internal
api'
,
'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'
]
]
];
];
src/ucenter/Label.php
View file @
02121869
...
@@ -24,6 +24,12 @@ class Label extends Client
...
@@ -24,6 +24,12 @@ class Label extends Client
const
TYPE_FAULT
=
6
;
// 故障点
const
TYPE_FAULT
=
6
;
// 故障点
const
TYPE_SPECIAL_TOPIC
=
7
;
// 专题
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=>品牌
* @param array/int $type 1=>认证 2=>品类 3=>品牌
*
*
...
@@ -49,4 +55,65 @@ class Label extends Client
...
@@ -49,4 +55,65 @@ class Label extends Client
return
self
::
call
(
'label.getListByLabels'
,
compact
(
'labels'
,
'types'
));
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'
));
}
}
}
src/ucenter/Message.php
View file @
02121869
...
@@ -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
());
}
}
}
src/ucenter/Notice.php
View file @
02121869
...
@@ -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
src/ucenter/Track.php
View file @
02121869
...
@@ -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
());
}
/**
/**
* 更新事件
* 更新事件
*
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment