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
84d0571c
Commit
84d0571c
authored
Feb 06, 2020
by
shajiaming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
fa321d80
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
121 additions
and
11 deletions
+121
-11
MarketController.php
api/controllers/MarketController.php
+51
-0
WalletChainController.php
api/controllers/WalletChainController.php
+5
-5
WalletChain.php
common/models/psources/WalletChain.php
+13
-6
CoinsControl.php
common/service/coin/CoinsControl.php
+52
-0
No files found.
api/controllers/MarketController.php
View file @
84d0571c
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
namespace
api\controllers
;
namespace
api\controllers
;
use
common\service\exchange\ExchangeFactory
;
use
Yii
;
use
Yii
;
use
api\base\BaseController
;
use
api\base\BaseController
;
use
common\service\exchange\ExchangeBuilderFactory
;
use
common\service\exchange\ExchangeBuilderFactory
;
...
@@ -32,4 +33,53 @@ class MarketController extends BaseController
...
@@ -32,4 +33,53 @@ class MarketController extends BaseController
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'tick'
=>
$ticker
??
[]];
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'tick'
=>
$ticker
??
[]];
}
}
public
function
actionIndex
()
{
$currency
=
Yii
::
$app
->
request
->
post
(
'currency'
,
''
);
$base_currency
=
Yii
::
$app
->
request
->
post
(
'base_currency'
,
''
);
$exchange
=
Yii
::
$app
->
request
->
post
(
"exchange"
,
'Zhaobi'
);
$base_exchange
=
Yii
::
$app
->
request
->
post
(
"base_exchange"
,
'Zhaobi'
);
if
(
false
==
$currency
||
false
==
$base_currency
)
{
$msg
=
'invalid symbol'
;
$code
=
-
1
;
goto
doEnd
;
}
$exchange
=
ExchangeFactory
::
createExchange
(
$exchange
);
$quotation
=
$exchange
->
getTicker
(
$currency
);
$quotation
=
[
'low'
=>
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'low'
]
/
100
),
'high'
=>
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'high'
]
/
100
),
'last'
=>
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'last'
]
/
100
),
'rmb'
=>
(
float
)
sprintf
(
"%0.2f"
,
$quotation
[
'last'
]
/
100
),
];
echo
json_encode
(
$quotation
);
exit
;
$base_exchange
=
ExchangeFactory
::
createExchange
(
$base_exchange
);
$base_quotation
=
$base_exchange
->
getTicker
(
$base_currency
);
$base_quotation
=
[
'low'
=>
(
float
)
sprintf
(
"%0.4f"
,
$base_quotation
[
'low'
]
/
100
),
'high'
=>
(
float
)
sprintf
(
"%0.4f"
,
$base_quotation
[
'high'
]
/
100
),
'last'
=>
(
float
)
sprintf
(
"%0.4f"
,
$base_quotation
[
'last'
]
/
100
),
'rmb'
=>
(
float
)
sprintf
(
"%0.2f"
,
$base_quotation
[
'last'
]
/
100
),
];
$builder
=
ExchangeBuilderFactory
::
create
(
'Zhaobi'
);
$result
=
$builder
->
getDetail
(
strtoupper
(
$currency
),
strtoupper
(
$base_currency
));
if
(
-
1
==
$result
[
'code'
])
{
$msg
=
'invalid symbol'
;
$code
=
-
1
;
goto
doEnd
;
}
$code
=
0
;
$msg
=
'ok'
;
$ticker
=
$result
[
'ticker'
];
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'tick'
=>
$ticker
??
[]];
}
}
}
\ No newline at end of file
api/controllers/WalletChainController.php
View file @
84d0571c
...
@@ -90,16 +90,16 @@ class WalletChainController extends BaseController
...
@@ -90,16 +90,16 @@ class WalletChainController extends BaseController
'host'
=>
isset
(
$post
[
'host'
])
?
$post
[
'host'
]
:
''
,
'host'
=>
isset
(
$post
[
'host'
])
?
$post
[
'host'
]
:
''
,
'port'
=>
isset
(
$post
[
'port'
])
?
$post
[
'port'
]
:
''
,
'port'
=>
isset
(
$post
[
'port'
])
?
$post
[
'port'
]
:
''
,
'wallet_address'
=>
isset
(
$post
[
'wallet_address'
])
?
$post
[
'wallet_address'
]
:
''
,
'wallet_address'
=>
isset
(
$post
[
'wallet_address'
])
?
$post
[
'wallet_address'
]
:
''
,
'hash'
=>
isset
(
$post
[
'hash'
])
?
$post
[
'hash'
]
:
''
,
'status'
=>
WalletChain
::
STATUS_NO
,
'origin'
=>
WalletChain
::
ORIGIN_MANAGE
,
'fee'
=>
isset
(
$post
[
'fee'
])
?
$post
[
'fee'
]
:
''
'fee'
=>
isset
(
$post
[
'fee'
])
?
$post
[
'fee'
]
:
''
];
];
if
(
$model
->
load
(
$params
,
''
)
&&
$model
->
save
())
{
if
(
$model
->
load
(
$params
,
''
)
&&
!
$model
->
save
())
{
goto
doEnd
;
}
$this
->
msg
=
$model
->
errors
;
$this
->
msg
=
$model
->
errors
;
$this
->
code
=
-
1
;
$this
->
code
=
-
1
;
goto
doEnd
;
}
doEnd
:
doEnd
:
return
[
'code'
=>
$this
->
code
,
'data'
=>
$this
->
data
,
'msg'
=>
$this
->
msg
];
return
[
'code'
=>
$this
->
code
,
'data'
=>
$this
->
data
,
'msg'
=>
$this
->
msg
];
...
...
common/models/psources/WalletChain.php
View file @
84d0571c
...
@@ -11,6 +11,12 @@ class WalletChain extends BaseActiveRecord
...
@@ -11,6 +11,12 @@ class WalletChain extends BaseActiveRecord
const
SCENARIOS_CREATE
=
'create'
;
const
SCENARIOS_CREATE
=
'create'
;
const
SCENARIOS_UPDATE
=
'update'
;
const
SCENARIOS_UPDATE
=
'update'
;
const
STATUS_NO
=
0
;
//创建失败
const
STATUS_YES
=
1
;
//创建成功
const
ORIGIN_MANAGE
=
1
;
//管理员创建
const
ORIGIN_USER
=
2
;
//h5用户创建
public
static
function
getDb
()
public
static
function
getDb
()
{
{
return
Yii
::
$app
->
get
(
'p_sources'
);
return
Yii
::
$app
->
get
(
'p_sources'
);
...
@@ -35,26 +41,27 @@ class WalletChain extends BaseActiveRecord
...
@@ -35,26 +41,27 @@ class WalletChain extends BaseActiveRecord
'host'
=>
'钱包服务IP'
,
'host'
=>
'钱包服务IP'
,
'port'
=>
'钱包服务端口'
,
'port'
=>
'钱包服务端口'
,
'wallet_address'
=>
'钱包地址'
,
'wallet_address'
=>
'钱包地址'
,
'hash'
=>
'申请费用hash'
'status'
=>
'申请状态'
,
'origin'
=>
'创建人'
];
];
}
}
public
function
rules
()
public
function
rules
()
{
{
return
[
return
[
[[
'platform'
,
'address'
,
'private_key'
,
'execer'
,
'brower_url'
,
'token'
,
'host'
,
'wallet_address'
,
'
hash'
,
'port'
,
'fee
'
],
'required'
],
[[
'platform'
,
'address'
,
'private_key'
,
'execer'
,
'brower_url'
,
'token'
,
'host'
,
'wallet_address'
,
'
status'
,
'port'
,
'fee'
,
'origin
'
],
'required'
],
[[
'platform'
,
'address'
,
'private_key'
,
'execer'
,
'brower_url'
,
'token'
,
'host'
,
'wallet_address'
,
'hash'
],
'string'
],
[[
'platform'
,
'address'
,
'private_key'
,
'execer'
,
'brower_url'
,
'token'
,
'host'
,
'wallet_address'
],
'string'
],
[[
'platform'
],
'string'
,
'length'
=>
[
1
,
30
]],
[[
'platform'
],
'string'
,
'length'
=>
[
1
,
30
]],
[[
'token'
],
'string'
,
'length'
=>
[
1
,
10
]],
[[
'token'
],
'string'
,
'length'
=>
[
1
,
10
]],
[[
'port'
],
'integer'
]
[[
'port'
,
'status'
,
'origin'
],
'integer'
]
];
];
}
}
public
function
scenarios
()
public
function
scenarios
()
{
{
$scenarios
=
[
$scenarios
=
[
self
::
SCENARIOS_CREATE
=>
[
'platform'
,
'token'
,
'address'
,
'private_key'
,
'fee'
,
'host'
,
'port'
,
'wallet_address'
,
'
hash
'
],
self
::
SCENARIOS_CREATE
=>
[
'platform'
,
'token'
,
'address'
,
'private_key'
,
'fee'
,
'host'
,
'port'
,
'wallet_address'
,
'
status'
,
'origin
'
],
self
::
SCENARIOS_UPDATE
=>
[
'platform'
,
'token'
,
'address'
,
'private_key'
,
'fee'
,
'host'
,
'port'
,
'wallet_address'
,
'
hash
'
],
self
::
SCENARIOS_UPDATE
=>
[
'platform'
,
'token'
,
'address'
,
'private_key'
,
'fee'
,
'host'
,
'port'
,
'wallet_address'
,
'
status'
,
'origin
'
],
];
];
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
}
}
...
...
common/service/coin/CoinsControl.php
0 → 100644
View file @
84d0571c
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-6-5
* Time: 上午11:17
*/
namespace
common\service\coin
;
use
Yii
;
use
common\helpers\Curl
;
/**
* 币种服务类
* Class CoinService
* @package common\service
*/
class
CoinsControl
{
protected
$url
;
public
function
__construct
()
{
$this
->
url
=
Yii
::
$app
->
params
[
'para'
][
'scheme'
]
.
'/'
.
Yii
::
$app
->
params
[
'para'
][
'host'
]
.
'/'
.
Yii
::
$app
->
params
[
'para'
][
'port'
];
}
public
function
init
()
{
$url
=
Yii
::
$app
->
params
[
'feixiaohao_domain'
]
.
Yii
::
$app
->
params
[
'feixiaohao_page'
][
'currencies'
]
.
$this
->
sid
.
'/'
;
$ch
=
new
Curl
();
$content
=
$ch
->
get
(
$url
,
true
);
$this
->
content
=
str_replace
([
' '
,
' '
],
''
,
$content
);
}
/**
* Gets the Article List ,Without Content field.
*
* @param number $page
* @param number $page_size
* @param string $language
* @return mixed
*/
public
function
getArticleList
(
$page
=
1
,
$page_size
=
20
,
$language
=
BISHIJIE_LANGUAGE_CN
)
{
$params
=
array
(
'language'
=>
$language
,
'page'
=>
$page
,
'size'
=>
$page_size
);
return
$this
->
get
(
'article/list'
,
$params
);
}
}
\ 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