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
4130d346
Commit
4130d346
authored
Jun 04, 2018
by
rlgy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
币种管理
parent
147c1747
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
84 additions
and
455 deletions
+84
-455
CoinController.php
api/controllers/CoinController.php
+27
-0
AdminController.php
backend/controllers/AdminController.php
+57
-59
LoginController.php
backend/controllers/LoginController.php
+0
-2
FxeeBusiness.php
common/business/FxeeBusiness.php
+0
-170
FxeeService.php
common/service/FxeeService.php
+0
-224
No files found.
api/controllers/CoinController.php
View file @
4130d346
...
...
@@ -10,6 +10,7 @@ namespace api\controllers;
use
api\base\BaseController
;
use
common\models\pwallet\Coin
;
use
Yii
;
/**
* 币种信息管理控制器
...
...
@@ -25,4 +26,29 @@ class CoinController extends BaseController
{
\Yii
::
$app
->
response
->
data
=
Coin
::
getList
();
}
/**
* 获取行情列表,可簺选(coin.id,coin.name),可分页
*
* @var int $id coin.id
* @var string $name coin.name
* @var int $page 第几页
* @var int $limit 多少条数据
*
* @return array 格式 [code,msg,count,data]
*
* 返回data数组格式[coin.id coin.name coin.nickname coin.quotation]
* coin.quatation=>['price' => '', 'dollar' => '', 'btc' => '', 'high' => '', 'low' => '', 'change' => '']
* 对应:价格 价格美元 价格btc 最高价 最低价 涨幅(跌幅)
*/
public
function
actionQuotationList
()
{
$request
=
Yii
::
$app
->
request
;
$id
=
$request
->
post
(
'id'
,
null
);
$name
=
$request
->
post
(
'name'
,
null
);
$page
=
$request
->
post
(
'page'
,
1
);
$limit
=
$request
->
post
(
'limit'
,
10
);
$condition
=
[
'id'
=>
$id
,
'name'
=>
$name
];
}
}
\ No newline at end of file
backend/controllers/AdminController.php
View file @
4130d346
...
...
@@ -4,8 +4,6 @@ namespace backend\controllers;
use
common\models\Admin
;
use
common\models\search\AdminSearch
;
use
common\business\FxeeBusiness
;
use
common\models\fxee\Member
;
use
common\core\Exception
;
use
Yii
;
...
...
@@ -78,62 +76,62 @@ class AdminController extends BaseController
* 用户授权
* ---------------------------------------
*/
public
function
actionAuth
()
{
/* 获取用户信息 */
$uid
=
Yii
::
$app
->
request
->
get
(
'uid'
);
if
(
!
is_numeric
(
$uid
)
||
!
(
$model
=
Admin
::
findOne
(
$uid
))
)
{
$this
->
error
(
'操作对象不合法'
);
}
$auth
=
Yii
::
$app
->
authManager
;
if
(
Yii
::
$app
->
request
->
isPost
)
{
$data
=
Yii
::
$app
->
request
->
post
();
//更新Fxee权限
try
{
$ret
=
FxeeBusiness
::
updateMemberGroup
(
$uid
,
isset
(
$data
[
'param_fxee'
])
?
$data
[
'param_fxee'
]
:
null
);
}
catch
(
Exception
$e
)
{
$ret
=
$e
->
getMessage
();
}
/* 用户权限组 */
$item_name
=
$data
[
'param'
];
/* 先删除 用户组-用户 记录 */
$auth
->
revokeAll
(
$uid
);
/* 再添加记录 */
$role
=
$auth
->
getRole
(
$item_name
);
$auth
->
assign
(
$role
,
$uid
);
//fxee用户权限操作
if
(
$ret
==
true
)
{
$this
->
success
(
'授权成功!'
,
$this
->
getForward
());
}
else
if
(
is_string
(
$ret
))
{
$this
->
error
(
$ret
);
}
exit
;
}
$roles
=
$auth
->
getRoles
();
$group
=
array_keys
(
$auth
->
getAssignments
(
$uid
));
$one
=
Admin
::
findOne
([
'uid'
=>
$uid
]);
if
(
isset
(
$one
[
'bind_uid'
])
&&
is_numeric
(
$one
[
'bind_uid'
]))
{
$fxeeRoles
=
Member
::
getRoles
();
$fxeeGroup
=
Member
::
find
()
->
select
(
'group'
)
->
where
([
'id'
=>
$one
[
'bind_uid'
]])
->
scalar
();
}
else
{
$fxeeRoles
=
$fxeeGroup
=
null
;
}
return
$this
->
render
(
'auth'
,
[
'model'
=>
$model
,
'roles'
=>
$roles
,
'group'
=>
$group
,
'fxee_roles'
=>
$fxeeRoles
,
'fxee_group'
=>
$fxeeGroup
,
]);
}
//
public function actionAuth()
//
{
//
/* 获取用户信息 */
//
$uid = Yii::$app->request->get('uid');
//
if (!is_numeric($uid) || !($model = Admin::findOne($uid)) ) {
//
$this->error('操作对象不合法');
//
}
//
//
$auth = Yii::$app->authManager;
//
if (Yii::$app->request->isPost) {
//
$data = Yii::$app->request->post();
//
//
//更新Fxee权限
//
try {
//
$ret = FxeeBusiness::updateMemberGroup($uid,isset($data['param_fxee']) ? $data['param_fxee'] : null);
//
} catch (Exception $e) {
//
$ret = $e->getMessage();
//
}
//
//
/* 用户权限组 */
//
$item_name = $data['param'];
//
//
/* 先删除 用户组-用户 记录 */
//
$auth->revokeAll($uid);
//
/* 再添加记录 */
//
$role = $auth->getRole($item_name);
//
$auth->assign($role, $uid);
//
//
//fxee用户权限操作
//
//
if ($ret == true) {
//
$this->success('授权成功!', $this->getForward());
//
} else if (is_string($ret)) {
//
$this->error($ret);
//
}
//
exit;
//
}
//
//
$roles = $auth->getRoles();
//
$group = array_keys($auth->getAssignments($uid));
//
//
$one = Admin::findOne(['uid' => $uid]);
//
if (isset($one['bind_uid']) && is_numeric($one['bind_uid'])) {
//
$fxeeRoles = Member::getRoles();
//
$fxeeGroup = Member::find()->select('group')->where(['id' => $one['bind_uid']])->scalar();
//
} else {
//
$fxeeRoles = $fxeeGroup = null;
//
}
//
//
return $this->render('auth', [
//
'model' => $model,
//
'roles' => $roles,
//
'group' => $group,
//
'fxee_roles' => $fxeeRoles,
//
'fxee_group' => $fxeeGroup,
//
]);
//
}
}
backend/controllers/LoginController.php
View file @
4130d346
...
...
@@ -4,9 +4,7 @@ namespace backend\controllers;
use
common\models\Admin
;
use
common\models\AdminSession
;
use
common\models\FxeeAuth
;
use
common\models\NewLoginForm
;
use
common\business\LoginBusiness
;
use
yii\filters\AccessControl
;
use
yii\web\Controller
;
use
yii\helpers\Url
;
...
...
common/business/FxeeBusiness.php
deleted
100644 → 0
View file @
147c1747
<?php
namespace
common\business
;
use
common\core\Exception
;
use
common\helpers\ArrayHelper
;
use
common\service\FxeeService
;
use
Yii
;
/**
* Fxee后台接口 逻辑
* Class FxeeBusiness
* @package common\business
*/
class
FxeeBusiness
{
/**
* [检查权限]
* @author: libingke
* @param string $url
* @param bool $returnJson
* @return bool
* @throws Exception
*/
public
static
function
checkAuthority
(
$key
,
$type
=
'get'
,
$returnJson
=
false
)
{
$ret
=
null
;
if
(
isset
(
Yii
::
$app
->
params
[
'fxee_backend'
][
$key
]))
{
if
(
in_array
(
$type
,
[
'post'
,
'get'
]))
{
}
else
{
$server
=
new
FxeeService
();
//$ret = $server->checkAuthority($key, $type);
}
}
else
{
$ret
=
'指向非法地址'
;
}
return
;
}
/**
* [更新用户权限]
* @author: libingke
* @return array
*/
public
static
function
updateMemberGroup
(
$uid
,
$group
)
{
if
(
!
is_numeric
(
$uid
))
throw
new
Exception
(
'UID格式错误'
);
if
(
!
in_array
(
$group
,
[
'admin'
,
'kf'
]))
throw
new
Exception
(
'无法选择该角色'
);
$server
=
new
FxeeService
();
return
$server
->
updateMemberGroup
(
$uid
,
$group
);
}
/**
* [获取支付列表]
* @author: libingke
* @param bool $hasAll
* @return array
*/
public
static
function
getPayList
(
$hasAll
=
true
)
{
$server
=
new
FxeeService
();
try
{
$ret
=
$server
->
getPayList
();
}
catch
(
Exception
$e
)
{
$ret
=
[];
}
$data
=
$hasAll
==
true
?
ArrayHelper
::
merge
([
''
=>
'全部'
],
$ret
)
:
$ret
;
return
$data
;
}
/**
* [获取热钱包数量]
* @author: libingke
* @return array
*/
public
static
function
getHotMoney
()
{
$server
=
new
FxeeService
();
try
{
return
$server
->
getHotMoney
();
}
catch
(
Exception
$e
)
{
return
[
'code'
=>
$e
->
getCode
(),
'message'
=>
$e
->
getMessage
()];
}
}
/**
* [获取证件类型]
* @author: libingke
* @return array
*/
public
static
function
getCardTypes
()
{
$server
=
new
FxeeService
();
try
{
return
$server
->
getCardTypes
();
}
catch
(
Exception
$e
)
{
return
[
[
'type'
=>
$e
->
getCode
(),
'name'
=>
$e
->
getMessage
()]
];
}
}
/**
* [获取证件类型]
* @author: libingke
* @param string $type
* @return array
*/
public
static
function
getCountry
(
$type
=
'name'
)
{
$type
=
in_array
(
$type
,
[
'code'
,
'name'
])
?
$type
:
'name'
;
$server
=
new
FxeeService
();
try
{
return
$server
->
getCountry
(
$type
);
}
catch
(
Exception
$e
)
{
return
[
[
'sname'
=>
$e
->
getCode
(),
'ch_name'
=>
$e
->
getMessage
()]
];
}
}
/**
* [获取用户实名列表]
* @author: libingke
* @return string
*/
public
static
function
getUploadToken
()
{
$userId
=
Yii
::
$app
->
user
->
id
;
$tokenCache
=
'upload_token_'
.
$userId
;
$token
=
Yii
::
$app
->
cache
->
get
(
$tokenCache
);
if
(
!
$token
)
{
$server
=
new
FxeeService
();
$data
=
$server
->
getUploadToken
();
$time
=
$data
[
'deadline'
]
-
time
()
-
30
;
$token
=
$data
[
'token'
];
Yii
::
$app
->
cache
->
set
(
$tokenCache
,
$data
[
'token'
],
$time
);
}
return
$token
;
}
/**
* [标准格式化参数]
* @param $params
* @return array
*/
public
static
function
formatParams
(
$params
)
{
$newParams
=
[];
isset
(
$params
[
'coin'
])
?
$newParams
[
'coin'
]
=
$params
[
'coin'
]
:
null
;
isset
(
$params
[
'start'
])
?
$newParams
[
'start'
]
=
$params
[
'start'
]
:
null
;
isset
(
$params
[
'end'
])
?
$newParams
[
'end'
]
=
$params
[
'end'
]
:
null
;
isset
(
$params
[
'user'
])
?
$newParams
[
'user'
]
=
$params
[
'user'
]
:
null
;
isset
(
$params
[
'page'
])
?
$newParams
[
'page'
]
=
$params
[
'page'
]
:
null
;
isset
(
$params
[
'size'
])
?
$newParams
[
'size'
]
=
$params
[
'size'
]
:
null
;
return
$newParams
;
}
}
\ No newline at end of file
common/service/FxeeService.php
deleted
100644 → 0
View file @
147c1747
<?php
namespace
common\service
;
use
common\models\Admin
;
use
common\models\FxeeAuth
;
use
common\core\Exception
;
use
common\helpers\Curl
;
use
Yii
;
/**
* Fxee后台接口
* Class FxeeService
* @package common\service
*/
class
FxeeService
{
private
$_domain
=
null
;
public
function
getDomain
()
{
if
(
!
$this
->
_domain
)
{
$this
->
_domain
=
Yii
::
$app
->
params
[
'fxee_domain'
];
}
return
$this
->
_domain
;
}
public
function
setDomain
(
$domain
)
{
if
(
$domain
)
$this
->
_domain
=
$domain
;
}
/**
* [获取token]
* @author: libingke
* @return string
*/
protected
function
getToken
()
{
$accessToken
=
Admin
::
fxeeAuth
()
->
access_token
;
return
$accessToken
;
}
protected
function
throwFxeeError
(
$result
)
{
if
(
$this
->
getToken
()
!=
null
&&
(
isset
(
$result
[
'code'
])
&&
$result
[
'code'
]
==
'-2'
))
{
FxeeAuth
::
deleteAll
([
'access_token'
=>
$this
->
getToken
()]);
Yii
::
$app
->
user
->
logout
();
}
Exception
::
fxeeException
(
$result
);
}
/**
* [获取支付列表]
* @author: libingke
* @return array
* @throws Exception
*/
public
function
getPayList
()
{
//$token = $this->getToken();
$url
=
$this
->
getDomain
()
.
Yii
::
$app
->
params
[
'fxee_backend'
][
'支付渠道列表'
];
$curl
=
new
Curl
();
//$curl->setHeader('Authorization', 'Bearer ' . $token);
$result
=
json_decode
(
$curl
->
get
(
$url
),
true
);
if
(
$curl
->
errorText
)
throw
new
Exception
(
$curl
->
errorText
);
$this
->
throwFxeeError
(
$result
);
return
is_array
(
$result
[
'data'
])
?
array_flip
(
$result
[
'data'
])
:
[];
}
/**
* [获取热钱包余额]
* @author: libingke
* @return array
*/
public
function
getHotMoney
()
{
$token
=
$this
->
getToken
();
$url
=
$this
->
getDomain
()
.
Yii
::
$app
->
params
[
'fxee_backend'
][
'热钱包余额'
];
$curl
=
new
Curl
();
$curl
->
setHeader
(
'Authorization'
,
'Bearer '
.
$token
);
$result
=
json_decode
(
$curl
->
get
(
$url
),
true
);
if
(
$curl
->
errorText
)
throw
new
Exception
(
$curl
->
errorText
);
return
$result
;
}
/**
* [更新用户权限]
* @author: libingke
* @return array
*/
public
function
updateMemberGroup
(
$uid
,
$group
)
{
$token
=
$this
->
getToken
();
$url
=
$this
->
getDomain
()
.
Yii
::
$app
->
params
[
'fxee_backend'
][
'更新用户权限'
];
$curl
=
new
Curl
();
$curl
->
setHeader
(
'Authorization'
,
'Bearer '
.
$token
);
$curl
->
setPostParams
([
'uid'
=>
$uid
,
'group'
=>
$group
]);
$result
=
json_decode
(
$curl
->
post
(
$url
),
true
);
if
(
$curl
->
errorText
)
throw
new
Exception
(
$curl
->
errorText
);
$this
->
throwFxeeError
(
$result
);
return
$result
;
}
/**
* [检查权限]
* @author: libingke
* @param string $key
* @param string $type
* @return bool
* @throws Exception
*/
public
function
checkAuthority
(
$key
,
$type
)
{
$token
=
$this
->
getToken
();
$url
=
$this
->
getDomain
()
.
Yii
::
$app
->
params
[
'fxee_backend'
][
$key
];
$curl
=
new
Curl
();
$curl
->
setHeader
(
'Authorization'
,
'Bearer '
.
$token
);
$result
=
json_decode
(
$curl
->
post
(
$url
),
true
);
if
(
$curl
->
errorText
)
throw
new
Exception
(
$curl
->
errorText
);
$this
->
throwFxeeError
(
$result
);
return
$result
;
}
/**
* [获取证件类型]
* @author: libingke
* @return array
* @throws Exception
*/
public
function
getCardTypes
()
{
$url
=
$this
->
getDomain
()
.
Yii
::
$app
->
params
[
'fxee_backend'
][
'证件类型'
];
$curl
=
new
Curl
();
$result
=
json_decode
(
$curl
->
get
(
$url
),
true
);
if
(
$curl
->
errorText
)
throw
new
Exception
(
$curl
->
errorText
);
$this
->
throwFxeeError
(
$result
);
return
is_array
(
$result
[
'data'
])
?
$result
[
'data'
]
:
[];
}
/**
* [获取国家信息]
* @author: libingke
* @param string $type 'code' | 'name'
* @return array
* @throws Exception
*/
public
function
getCountry
(
$type
)
{
$url
=
$this
->
getDomain
()
.
Yii
::
$app
->
params
[
'fxee_backend'
][
'国家信息'
];
$curl
=
new
Curl
();
$curl
->
setGetParams
([
'type'
=>
$type
]);
$result
=
json_decode
(
$curl
->
get
(
$url
),
true
);
if
(
$curl
->
errorText
)
throw
new
Exception
(
$curl
->
errorText
);
$this
->
throwFxeeError
(
$result
);
return
is_array
(
$result
[
'data'
])
?
$result
[
'data'
]
:
[];
}
/**
* [获取上传token]
* @author: libingke
* @return []
*/
public
function
getUploadToken
()
{
$token
=
$this
->
getToken
();
//$token = '86a6e06a2a67c2a407bb45e258b5b15075688968';
$url
=
Yii
::
$app
->
params
[
'fxee_backend'
][
'获取上传token'
];
$curl
=
new
Curl
();
$curl
->
setHeader
(
'Authorization'
,
'Bearer '
.
$token
);
$result
=
json_decode
(
$curl
->
post
(
$url
),
true
);
if
(
$curl
->
errorText
)
throw
new
Exception
(
$curl
->
errorText
);
$this
->
throwFxeeError
(
$result
);
return
is_array
(
$result
[
'data'
])
?
$result
[
'data'
]
:
[];
}
}
\ 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