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
4b890404
Commit
4b890404
authored
Jun 27, 2019
by
杨培
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
支付消息队列异步调用指定接口,增加跟踪事件异步接口
parent
c4738f3e
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
87 additions
and
10 deletions
+87
-10
ucenter_test.php
example/ucenter_test.php
+3
-6
ucenter_track.php
example/ucenter_track.php
+7
-1
Client.php
src/base/Client.php
+64
-0
client_config_dev.php
src/client_config_dev.php
+6
-1
client_config_prod.php
src/client_config_prod.php
+1
-1
client_config_test.php
src/client_config_test.php
+1
-1
Track.php
src/ucenter/Track.php
+5
-0
No files found.
example/ucenter_test.php
View file @
4b890404
...
@@ -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 @
4b890404
...
@@ -10,4 +10,10 @@ use internalApi\ucenter\Track;
...
@@ -10,4 +10,10 @@ use internalApi\ucenter\Track;
require
__DIR__
.
'/_init.php'
;
require
__DIR__
.
'/_init.php'
;
echo
Track
::
track
(
'test'
);
//echo Track::track('test');
$ret
=
Track
::
trackAsync
(
'test'
,
12
,
time
(),
[
'测试属性'
=>
'属性值'
,
'_protectedProperty'
=>
'propertyValue'
]);
print_r
(
$ret
);
src/base/Client.php
View file @
4b890404
...
@@ -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/client_config_dev.php
View file @
4b890404
...
@@ -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 @
4b890404
...
@@ -33,7 +33,7 @@ return [
...
@@ -33,7 +33,7 @@ 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'
]
]
...
...
src/client_config_test.php
View file @
4b890404
...
@@ -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'
],
],
...
...
src/ucenter/Track.php
View file @
4b890404
...
@@ -31,6 +31,11 @@ class Track extends Client
...
@@ -31,6 +31,11 @@ class Track extends Client
return
self
::
call
(
'track.track'
,
compact
(
'event'
,
'uid'
,
'time'
,
'props'
));
return
self
::
call
(
'track.track'
,
compact
(
'event'
,
'uid'
,
'time'
,
'props'
));
}
}
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