Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
token
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wallet
token
Commits
bcae8583
Commit
bcae8583
authored
Aug 05, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
请求托管时增加校验
parent
674ffd86
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
30 deletions
+64
-30
TrusteeShipService.php
common/service/trusteeship/TrusteeShipService.php
+12
-27
BaseController.php
wallet/base/BaseController.php
+11
-0
UserController.php
wallet/controllers/UserController.php
+13
-1
WalletController.php
wallet/controllers/WalletController.php
+28
-2
No files found.
common/service/trusteeship/TrusteeShipService.php
View file @
bcae8583
...
@@ -8,10 +8,15 @@ use common\helpers\Curl;
...
@@ -8,10 +8,15 @@ use common\helpers\Curl;
class
TrusteeShipService
class
TrusteeShipService
{
{
private
$node_params
;
private
$node_params
;
private
$header
;
public
function
__construct
(
$parameter
=
[])
public
function
__construct
(
$parameter
=
[]
,
$header
=
[]
)
{
{
$platform_id
=
Yii
::
$app
->
request
->
getPlatformId
();
$platform_id
=
Yii
::
$app
->
request
->
getPlatformId
();
if
(
!
empty
(
$header
))
{
$this
->
header
=
$header
;
}
if
(
empty
(
$parameter
))
{
if
(
empty
(
$parameter
))
{
$this
->
node_params
=
Yii
::
$app
->
params
[
'trusteeship'
][
'node_'
.
$platform_id
][
'url'
];
$this
->
node_params
=
Yii
::
$app
->
params
[
'trusteeship'
][
'node_'
.
$platform_id
][
'url'
];
}
else
{
}
else
{
...
@@ -25,16 +30,17 @@ class TrusteeShipService
...
@@ -25,16 +30,17 @@ class TrusteeShipService
}
}
public
function
send
(
$method
=
'GET'
,
$uri
,
$params
=
[]
,
$headers
=
[]
)
public
function
send
(
$method
=
'GET'
,
$uri
,
$params
=
[])
{
{
$ch
=
new
Curl
();
$ch
=
new
Curl
();
if
(
!
empty
(
$headers
))
{
if
(
!
empty
(
$this
->
header
))
{
$ch
->
setHeaders
(
$
headers
);
$ch
->
setHeaders
(
$
this
->
header
);
}
}
if
(
!
empty
(
$params
))
{
if
(
!
empty
(
$params
))
{
$ch
->
setGetParams
(
$params
);
$ch
->
setGetParams
(
$params
);
}
}
$result
=
$ch
->
$method
(
$this
->
urlBuild
(
$uri
),
false
);
$result
=
$ch
->
$method
(
$this
->
urlBuild
(
$uri
),
false
);
if
(
!
$result
)
{
if
(
!
$result
)
{
return
[
'code'
=>
-
1
,
'msg'
=>
$ch
->
errorText
];
return
[
'code'
=>
-
1
,
'msg'
=>
$ch
->
errorText
];
...
@@ -57,21 +63,7 @@ class TrusteeShipService
...
@@ -57,21 +63,7 @@ class TrusteeShipService
{
{
$uri
=
'backend/account/wallet-balance'
;
$uri
=
'backend/account/wallet-balance'
;
$time
=
time
();
return
$this
->
send
(
"GET"
,
$uri
,
$params
);
$platform_id
=
Yii
::
$app
->
request
->
getPlatformId
();
$node_params
=
Yii
::
$app
->
params
[
'trusteeship'
][
'node_'
.
$platform_id
];
$appKey
=
isset
(
$node_params
[
'appKey'
])
?
$node_params
[
'appKey'
]
:
null
;
$appSecret
=
isset
(
$node_params
[
'appSecret'
])
?
$node_params
[
'appSecret'
]
:
null
;
$signature
=
self
::
getSign
(
$params
,
$appKey
,
$appSecret
,
$time
);
$headers
=
[
'FZM-Wallet-Signature'
=>
$signature
,
'FZM-Wallet-Timestamp'
=>
$time
,
'FZM-Wallet-AppKey'
=>
$appKey
,
'FZM-Wallet-AppIp'
=>
Yii
::
$app
->
request
->
userIP
];
return
$this
->
send
(
"GET"
,
$uri
,
$params
,
$headers
);
}
}
public
function
getUserAsset
(
$params
=
[])
public
function
getUserAsset
(
$params
=
[])
...
@@ -81,12 +73,5 @@ class TrusteeShipService
...
@@ -81,12 +73,5 @@ class TrusteeShipService
return
$this
->
send
(
"GET"
,
$uri
,
$params
);
return
$this
->
send
(
"GET"
,
$uri
,
$params
);
}
}
protected
function
getSign
(
$params
,
$appkey
,
$appSecret
,
$time
)
{
ksort
(
$params
);
$string
=
http_build_query
(
$params
);
$result
=
md5
(
$appkey
.
$string
.
$appSecret
.
$time
);
$sign
=
strtoupper
(
$result
);
return
$sign
;
}
}
}
wallet/base/BaseController.php
View file @
bcae8583
...
@@ -322,4 +322,14 @@ class BaseController extends Controller
...
@@ -322,4 +322,14 @@ class BaseController extends Controller
}
}
return
$params
;
return
$params
;
}
}
protected
function
getSign
(
$params
,
$appkey
,
$appSecret
,
$time
)
{
ksort
(
$params
);
$string
=
http_build_query
(
$params
);
$result
=
md5
(
$appkey
.
$string
.
$appSecret
.
$time
);
$sign
=
strtoupper
(
$result
);
return
$sign
;
}
}
}
\ No newline at end of file
wallet/controllers/UserController.php
View file @
bcae8583
...
@@ -155,7 +155,19 @@ class UserController extends BaseController
...
@@ -155,7 +155,19 @@ class UserController extends BaseController
'end_time'
=>
$end_time
'end_time'
=>
$end_time
];
];
$service
=
new
TrusteeShipService
(
$node_params
);
$time
=
time
();
$appKey
=
isset
(
$node_params
[
'appKey'
])
?
$node_params
[
'appKey'
]
:
null
;
$appSecret
=
isset
(
$node_params
[
'appSecret'
])
?
$node_params
[
'appSecret'
]
:
null
;
$signature
=
self
::
getSign
(
$params
,
$appKey
,
$appSecret
,
$time
);
$headers
=
[
'FZM-Wallet-Signature'
=>
$signature
,
'FZM-Wallet-Timestamp'
=>
$time
,
'FZM-Wallet-AppKey'
=>
$appKey
,
'FZM-Wallet-AppIp'
=>
Yii
::
$app
->
request
->
userIP
];
$service
=
new
TrusteeShipService
(
$node_params
,
$headers
);
$result
=
$service
->
getUserList
(
$params
);
$result
=
$service
->
getUserList
(
$params
);
if
(
200
!==
$result
[
'code'
])
{
if
(
200
!==
$result
[
'code'
])
{
return
[
'code'
=>
$result
[
'code'
],
'data'
=>
[],
'msg'
=>
$result
[
'msg'
]];
return
[
'code'
=>
$result
[
'code'
],
'data'
=>
[],
'msg'
=>
$result
[
'msg'
]];
...
...
wallet/controllers/WalletController.php
View file @
bcae8583
...
@@ -53,7 +53,19 @@ class WalletController extends BaseController
...
@@ -53,7 +53,19 @@ class WalletController extends BaseController
'size'
=>
$size
,
'size'
=>
$size
,
'currency'
=>
$currency
'currency'
=>
$currency
];
];
$service
=
new
TrusteeShipService
(
$node_params
);
$time
=
time
();
$appKey
=
isset
(
$node_params
[
'appKey'
])
?
$node_params
[
'appKey'
]
:
null
;
$appSecret
=
isset
(
$node_params
[
'appSecret'
])
?
$node_params
[
'appSecret'
]
:
null
;
$signature
=
self
::
getSign
(
$params
,
$appKey
,
$appSecret
,
$time
);
$headers
=
[
'FZM-Wallet-Signature'
=>
$signature
,
'FZM-Wallet-Timestamp'
=>
$time
,
'FZM-Wallet-AppKey'
=>
$appKey
,
'FZM-Wallet-AppIp'
=>
Yii
::
$app
->
request
->
userIP
];
$service
=
new
TrusteeShipService
(
$node_params
,
$headers
);
$result
=
$service
->
getWalletBalance
(
$params
);
$result
=
$service
->
getWalletBalance
(
$params
);
if
(
200
!==
$result
[
'code'
])
{
if
(
200
!==
$result
[
'code'
])
{
return
[
'code'
=>
$result
[
'code'
],
'data'
=>
[],
'msg'
=>
$result
[
'msg'
]];
return
[
'code'
=>
$result
[
'code'
],
'data'
=>
[],
'msg'
=>
$result
[
'msg'
]];
...
@@ -69,11 +81,24 @@ class WalletController extends BaseController
...
@@ -69,11 +81,24 @@ class WalletController extends BaseController
$params
=
[
$params
=
[
'uid'
=>
$uid
'uid'
=>
$uid
];
];
$service
=
new
TrusteeShipService
(
$node_params
);
$time
=
time
();
$appKey
=
isset
(
$node_params
[
'appKey'
])
?
$node_params
[
'appKey'
]
:
null
;
$appSecret
=
isset
(
$node_params
[
'appSecret'
])
?
$node_params
[
'appSecret'
]
:
null
;
$signature
=
self
::
getSign
(
$params
,
$appKey
,
$appSecret
,
$time
);
$headers
=
[
'FZM-Wallet-Signature'
=>
$signature
,
'FZM-Wallet-Timestamp'
=>
$time
,
'FZM-Wallet-AppKey'
=>
$appKey
,
'FZM-Wallet-AppIp'
=>
Yii
::
$app
->
request
->
userIP
];
$service
=
new
TrusteeShipService
(
$node_params
,
$headers
);
$result
=
$service
->
getUserAsset
(
$params
);
$result
=
$service
->
getUserAsset
(
$params
);
if
(
200
!==
$result
[
'code'
])
{
if
(
200
!==
$result
[
'code'
])
{
return
[
'code'
=>
$result
[
'code'
],
'data'
=>
[],
'msg'
=>
$result
[
'msg'
]];
return
[
'code'
=>
$result
[
'code'
],
'data'
=>
[],
'msg'
=>
$result
[
'msg'
]];
}
}
return
[
'code'
=>
1
,
'data'
=>
$result
[
'msg'
],
'msg'
=>
'success'
];
return
[
'code'
=>
1
,
'data'
=>
$result
[
'msg'
],
'msg'
=>
'success'
];
}
}
}
}
\ No newline at end of file
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