Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
web_push
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨苏杭
web_push
Commits
b692e548
Commit
b692e548
authored
Nov 20, 2018
by
banice
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加super_agent_id
parent
17dad6f8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
6 deletions
+52
-6
Application/Events.php
+50
-4
Lib/Log.php
+2
-2
No files found.
Application/Events.php
View file @
b692e548
...
@@ -29,14 +29,16 @@ class Events
...
@@ -29,14 +29,16 @@ class Events
}
}
/**
/**
* @param $clientId
* @param $clientId
* @param $message
* @param $message
* @throws
\GuzzleHttp\Exception\Guzzle
Exception
* @throws Exception
*/
*/
public
static
function
onMessage
(
$clientId
,
$message
)
public
static
function
onMessage
(
$clientId
,
$message
)
{
{
$request
=
json_decode
(
$message
,
true
);
$request
=
json_decode
(
$message
,
true
);
if
(
isset
(
$request
[
'command'
])
===
false
)
{
if
(
isset
(
$request
[
'command'
])
===
false
)
{
...
@@ -45,6 +47,9 @@ class Events
...
@@ -45,6 +47,9 @@ class Events
}
}
\Lib\Log
::
debug
(
$message
);
$command
=
$request
[
'command'
];
$command
=
$request
[
'command'
];
...
@@ -89,15 +94,56 @@ class Events
...
@@ -89,15 +94,56 @@ class Events
if
(
$command
==
'02'
)
{
if
(
$command
==
'02'
)
{
$agentId
=
$request
[
'agent_id'
];
$agentId
=
$request
[
'agent_id'
];
if
(
isset
(
$request
[
'super_agent_id'
]))
{
if
(
isset
(
$request
[
'super_agent_id'
]))
{
if
(
isset
(
$request
[
'super_agent_id'
][
0
]))
{
$superAgentId
=
$request
[
'super_agent_id'
][
0
];
$redis
=
new
\Redis
();
Gateway
::
bindUid
(
$superAgentId
,
$agentId
);
$redis
->
connect
(
'redis.test.senthink.com'
);
$redis
->
select
(
4
);
$redis
->
multi
(
2
);
foreach
(
$request
[
'super_agent_id'
]
as
$id
)
{
$redis
->
hSet
(
'cdz:super_agent_id:hash'
,
$id
,
$id
);
}
}
$redis
->
exec
();
$redis
->
close
();
}
}
Gateway
::
bindUid
(
$clientId
,
$agentId
);
Gateway
::
bindUid
(
$clientId
,
$agentId
);
Gateway
::
sendToCurrentClient
(
json_encode
([
'code'
=>
200
]));
Gateway
::
sendToCurrentClient
(
json_encode
([
'code'
=>
200
]));
return
;
}
if
(
$command
==
'03'
)
{
$token
=
$request
[
'token'
];
$client
=
new
Client
([
'base_uri'
=>
'https://hdg-user-api.test.senthink.com'
,
]);
$response
=
$client
->
request
(
'POST'
,
'api/wx/token/confirm'
,
[
'headers'
=>
[
'Authorization'
=>
'Bearer '
.
$token
,
'Accept'
=>
'application/json'
,
]
]);
if
(
$response
->
getStatusCode
()
===
200
)
{
$body
=
json_decode
(
$response
->
getBody
(),
true
);
Gateway
::
setSession
(
$clientId
,
$body
);
$userId
=
$body
[
'id'
];
Gateway
::
bindUid
(
$clientId
,
'hdg'
.
$userId
);
Gateway
::
sendToCurrentClient
(
json_encode
([
'return_code'
=>
200
,
'result_code'
=>
"SUCCESS"
]));
return
;
return
;
}
else
{
Gateway
::
sendToCurrentClient
(
json_encode
([
'return_code'
=>
200
,
'result_code'
=>
'FAIL'
]));
return
;
}
}
}
...
...
Lib/Log.php
View file @
b692e548
...
@@ -18,7 +18,7 @@ use Monolog\Logger;
...
@@ -18,7 +18,7 @@ use Monolog\Logger;
* @method static warn($info, $context = [])
* @method static warn($info, $context = [])
* @method static alert($info, $context = [])
* @method static alert($info, $context = [])
* @method static error($info, $context = [])
* @method static error($info, $context = [])
*
*
@method static debug($info, $context = [])
* Class Log
* Class Log
* @package Lib
* @package Lib
*/
*/
...
@@ -65,7 +65,7 @@ class Log
...
@@ -65,7 +65,7 @@ class Log
public
static
function
__callStatic
(
$name
,
$arguments
)
public
static
function
__callStatic
(
$name
,
$arguments
)
{
{
return
call_user_func_array
([
static
::
$log
,
$name
],
$arguments
);
return
call_user_func_array
([
static
::
$log
,
$name
],
$arguments
);
}
}
...
...
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