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
9a9a1dc7
Commit
9a9a1dc7
authored
Nov 21, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
计价货币
parent
f693ddea
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
103 additions
and
35 deletions
+103
-35
BaseController.php
api/base/BaseController.php
+12
-4
CoinController.php
api/controllers/CoinController.php
+9
-1
TickerController.php
api/controllers/TickerController.php
+33
-3
CoinCurrency.php
common/models/psources/CoinCurrency.php
+3
-3
CoinSupportedCurrency.php
common/models/psources/CoinSupportedCurrency.php
+5
-0
TickerController.php
console/controllers/TickerController.php
+37
-8
WalletController.php
wallet/controllers/WalletController.php
+4
-16
No files found.
api/base/BaseController.php
View file @
9a9a1dc7
...
@@ -19,12 +19,14 @@ class BaseController extends Controller
...
@@ -19,12 +19,14 @@ class BaseController extends Controller
public
$header_list
=
[];
public
$header_list
=
[];
public
$lang
;
public
$lang
;
public
$currency_id
;
public
$platform_id
;
private
static
$default_header_list
=
[];
private
static
$default_header_list
=
[];
public
function
init
()
public
function
init
()
{
{
if
(
'cli'
!==
php_sapi_name
()){
if
(
'cli'
!==
php_sapi_name
())
{
$this
->
header_list
=
self
::
$default_header_list
;
$this
->
header_list
=
self
::
$default_header_list
;
$this
->
fzmCrossHeader
();
$this
->
fzmCrossHeader
();
}
}
...
@@ -33,9 +35,15 @@ class BaseController extends Controller
...
@@ -33,9 +35,15 @@ class BaseController extends Controller
public
function
fzmCrossHeader
()
public
function
fzmCrossHeader
()
{
{
$this
->
lang
=
\Yii
::
$app
->
request
->
headers
->
get
(
'lang'
)
??
'zh-CN'
;
$this
->
lang
=
\Yii
::
$app
->
request
->
headers
->
get
(
'lang'
)
??
'zh-CN'
;
if
(
'en'
==
strtolower
(
$this
->
lang
)){
if
(
'en'
==
strtolower
(
$this
->
lang
))
{
$this
->
lang
=
'en-US'
;
$this
->
lang
=
'en-US'
;
}
}
if
(
\Yii
::
$app
->
request
->
headers
->
get
(
'FZM-PLATFORM-ID'
))
{
$this
->
platform_id
=
\Yii
::
$app
->
request
->
headers
->
get
(
'FZM-PLATFORM-ID'
);
}
if
(
\Yii
::
$app
->
request
->
headers
->
get
(
'FZM-CURRENCY-ID'
))
{
$this
->
currency_id
=
\Yii
::
$app
->
request
->
headers
->
get
(
'FZM-CURRENCY-ID'
);
}
}
}
public
function
beforeAction
(
$action
)
public
function
beforeAction
(
$action
)
...
@@ -75,7 +83,7 @@ class BaseController extends Controller
...
@@ -75,7 +83,7 @@ class BaseController extends Controller
'errmsg'
=>
$errmsg
,
'errmsg'
=>
$errmsg
,
];
];
if
(
$data
!==
null
)
{
if
(
$data
!==
null
)
{
$result
[
'data'
]
=
Yii
::
createObject
(
'yii\rest\Serializer'
)
->
serialize
(
$data
);
$result
[
'data'
]
=
Yii
::
createObject
(
'yii\rest\Serializer'
)
->
serialize
(
$data
);
}
}
...
@@ -83,7 +91,7 @@ class BaseController extends Controller
...
@@ -83,7 +91,7 @@ class BaseController extends Controller
$response
->
format
=
Response
::
FORMAT_JSON
;
$response
->
format
=
Response
::
FORMAT_JSON
;
//jsonp数据格式
//jsonp数据格式
if
(
!
is_null
(
$callback
))
{
if
(
!
is_null
(
$callback
))
{
Yii
::
$app
->
getResponse
()
->
format
=
Response
::
FORMAT_JSONP
;
Yii
::
$app
->
getResponse
()
->
format
=
Response
::
FORMAT_JSONP
;
$result
=
[
$result
=
[
'data'
=>
$result
,
'data'
=>
$result
,
...
...
api/controllers/CoinController.php
View file @
9a9a1dc7
...
@@ -15,6 +15,7 @@ use common\business\Chain33Business;
...
@@ -15,6 +15,7 @@ use common\business\Chain33Business;
use
common\business\CoinBusiness
;
use
common\business\CoinBusiness
;
use
common\business\ExchangeBusiness
;
use
common\business\ExchangeBusiness
;
use
common\models\psources\Coin
;
use
common\models\psources\Coin
;
use
common\models\psources\CoinCurrency
;
use
common\models\psources\CoinPlatformWithHold
;
use
common\models\psources\CoinPlatformWithHold
;
use
common\models\psources\CoinRecommend
;
use
common\models\psources\CoinRecommend
;
use
common\models\psources\MinerFee
;
use
common\models\psources\MinerFee
;
...
@@ -243,6 +244,12 @@ class CoinController extends BaseController
...
@@ -243,6 +244,12 @@ class CoinController extends BaseController
foreach
(
$chains
as
$key
=>
$value
)
{
foreach
(
$chains
as
$key
=>
$value
)
{
$chain_quotation
[
$value
]
=
ExchangeBusiness
::
getquatation
(
$value
);
$chain_quotation
[
$value
]
=
ExchangeBusiness
::
getquatation
(
$value
);
}
}
$currency
=
CoinCurrency
::
find
()
->
where
([
'pj_id'
=>
$this
->
currency_id
])
->
one
();
if
(
false
!=
$currency
)
{
$last
=
Yii
::
$app
->
redis_currency
->
hmget
(
'quotation_boc_'
.
'CNY_'
.
$currency
->
symbol
,
'last'
);
}
foreach
(
$result
[
'data'
]
as
$key
=>
&
$value
)
{
foreach
(
$result
[
'data'
]
as
$key
=>
&
$value
)
{
if
(
!
isset
(
$value
[
'nickname'
])
||
empty
(
$value
[
'nickname'
]))
continue
;
if
(
!
isset
(
$value
[
'nickname'
])
||
empty
(
$value
[
'nickname'
]))
continue
;
$nickname
=
json_decode
(
$value
[
'nickname'
],
true
);
$nickname
=
json_decode
(
$value
[
'nickname'
],
true
);
...
@@ -252,6 +259,7 @@ class CoinController extends BaseController
...
@@ -252,6 +259,7 @@ class CoinController extends BaseController
$value
[
'chain_quotation'
]
=
$chain_quotation
[
$value
[
'chain'
]]
?:
null
;
$value
[
'chain_quotation'
]
=
$chain_quotation
[
$value
[
'chain'
]]
?:
null
;
$value
[
'chain_rmb'
]
=
isset
(
$value
[
'chain_quotation'
][
'rmb'
])
?
$value
[
'chain_quotation'
][
'rmb'
]
:
0
;
$value
[
'chain_rmb'
]
=
isset
(
$value
[
'chain_quotation'
][
'rmb'
])
?
$value
[
'chain_quotation'
][
'rmb'
]
:
0
;
$value
[
'chain_usd'
]
=
isset
(
$value
[
'chain_quotation'
][
'usd'
])
?
$value
[
'chain_quotation'
][
'usd'
]
:
0
;
$value
[
'chain_usd'
]
=
isset
(
$value
[
'chain_quotation'
][
'usd'
])
?
$value
[
'chain_quotation'
][
'usd'
]
:
0
;
$value
[
'country_rate'
]
=
(
false
==
$currency
)
?
''
:
(
float
)
sprintf
(
"%0.4f"
,
$last
[
0
]
*
$value
[
'rmb'
]);
}
}
return
$result
;
return
$result
;
}
}
...
@@ -365,7 +373,7 @@ class CoinController extends BaseController
...
@@ -365,7 +373,7 @@ class CoinController extends BaseController
if
(
1
==
$coin_info
[
'treaty'
])
{
if
(
1
==
$coin_info
[
'treaty'
])
{
$platform_with_hold
[
'exer'
]
=
'user.p.'
.
$platform
.
'.token'
;
$platform_with_hold
[
'exer'
]
=
'user.p.'
.
$platform
.
'.token'
;
if
(
'BTY'
!==
strtoupper
(
$platform
))
{
if
(
'BTY'
!==
strtoupper
(
$platform
))
{
$platform_with_hold
[
'tokensymbol'
]
=
$platform
.
'.'
.
$coin_name
;
$platform_with_hold
[
'tokensymbol'
]
=
$platform
.
'.'
.
$coin_name
;
}
else
{
}
else
{
$platform_with_hold
[
'tokensymbol'
]
=
$coin_name
;
$platform_with_hold
[
'tokensymbol'
]
=
$coin_name
;
}
}
...
...
api/controllers/TickerController.php
View file @
9a9a1dc7
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
namespace
api\controllers
;
namespace
api\controllers
;
use
common\components\Tools
;
use
common\components\Tools
;
use
common\models\psources\CoinCurrency
;
use
common\models\psources\CoinSupportedCurrency
;
use
Yii
;
use
Yii
;
use
yii\data\Pagination
;
use
yii\data\Pagination
;
use
linslin\yii2\curl\Curl
;
use
linslin\yii2\curl\Curl
;
...
@@ -291,7 +293,7 @@ class TickerController extends BaseController
...
@@ -291,7 +293,7 @@ class TickerController extends BaseController
'btcusdt'
,
'btcusdt'
,
'ethusdt'
'ethusdt'
]
]
],[
],
[
'exchange'
=>
'zhaobi'
,
'exchange'
=>
'zhaobi'
,
'symbol'
=>
[
'symbol'
=>
[
'btyusdt'
'btyusdt'
...
@@ -306,7 +308,7 @@ class TickerController extends BaseController
...
@@ -306,7 +308,7 @@ class TickerController extends BaseController
'btcusdt'
,
'btcusdt'
,
'ethusdt'
'ethusdt'
],
],
],[
],
[
'exchange'
=>
'dag'
,
'exchange'
=>
'dag'
,
'symbol'
=>
[
'symbol'
=>
[
'dagusdt'
'dagusdt'
...
@@ -322,7 +324,7 @@ class TickerController extends BaseController
...
@@ -322,7 +324,7 @@ class TickerController extends BaseController
'btcusdt'
,
'btcusdt'
,
'ethusdt'
'ethusdt'
],
],
],[
],
[
'exchange'
=>
'bitnasdaq'
,
'exchange'
=>
'bitnasdaq'
,
'symbol'
=>
[
'symbol'
=>
[
'bncusdt'
'bncusdt'
...
@@ -344,4 +346,31 @@ class TickerController extends BaseController
...
@@ -344,4 +346,31 @@ class TickerController extends BaseController
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
}
}
public
function
actionCurrency
()
{
$code
=
0
;
$data
=
null
;
$platform_id
=
$this
->
platform_id
;
if
(
false
==
$platform_id
)
{
$code
=
-
1
;
$msg
=
'请求参数错误!'
;
goto
doEnd
;
}
$currency
=
CoinSupportedCurrency
::
find
()
->
where
([
'platform_id'
=>
$platform_id
])
->
all
();
foreach
(
$currency
as
$val
)
{
$val
->
pj_id
=
$val
->
currency
->
pj_id
;
$val
->
pj_name
=
$val
->
currency
->
pj_name
;
$val
->
pj_symbol
=
$val
->
currency
->
pj_symbol
;
unset
(
$val
->
id
);
unset
(
$val
->
platform_id
);
unset
(
$val
->
currency_id
);
}
$data
=
$currency
;
$code
=
0
;
$msg
=
'success'
;
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
}
}
}
\ No newline at end of file
common/models/psources/CoinCurrency.php
View file @
9a9a1dc7
...
@@ -26,7 +26,7 @@ class CoinCurrency extends BaseActiveRecord
...
@@ -26,7 +26,7 @@ class CoinCurrency extends BaseActiveRecord
{
{
return
[
return
[
[[
'pj_id'
,
'pj_name'
],
'required'
],
[[
'pj_id'
,
'pj_name'
],
'required'
],
[[
'
icon
'
,
'lang'
],
'safe'
],
[[
'
pj_symbol
'
,
'lang'
],
'safe'
],
[[
'platform_id'
,
'currency_id'
],
'integer'
],
[[
'platform_id'
,
'currency_id'
],
'integer'
],
];
];
}
}
...
@@ -42,8 +42,8 @@ class CoinCurrency extends BaseActiveRecord
...
@@ -42,8 +42,8 @@ class CoinCurrency extends BaseActiveRecord
public
function
scenarios
()
public
function
scenarios
()
{
{
$scenarios
=
[
$scenarios
=
[
self
::
SCENARIOS_CREATE
=>
[
'pj_id'
,
'pj_name'
,
'
icon
'
,
'lang'
],
self
::
SCENARIOS_CREATE
=>
[
'pj_id'
,
'pj_name'
,
'
pj_symbol
'
,
'lang'
],
self
::
SCENARIOS_UPDATE
=>
[
'id'
,
'pj_id'
,
'pj_name'
,
'
icon
'
,
'lang'
],
self
::
SCENARIOS_UPDATE
=>
[
'id'
,
'pj_id'
,
'pj_name'
,
'
pj_symbol
'
,
'lang'
],
];
];
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
}
}
...
...
common/models/psources/CoinSupportedCurrency.php
View file @
9a9a1dc7
...
@@ -48,6 +48,11 @@ class CoinSupportedCurrency extends BaseActiveRecord
...
@@ -48,6 +48,11 @@ class CoinSupportedCurrency extends BaseActiveRecord
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
}
}
public
function
attributes
()
{
return
array_merge
(
parent
::
attributes
(),
[
'pj_id'
,
'pj_name'
,
'pj_symbol'
]);
}
public
function
getCurrency
()
public
function
getCurrency
()
{
{
return
$this
->
hasOne
(
CoinCurrency
::
className
(),
[
'id'
=>
'currency_id'
]);
return
$this
->
hasOne
(
CoinCurrency
::
className
(),
[
'id'
=>
'currency_id'
]);
...
...
console/controllers/TickerController.php
View file @
9a9a1dc7
...
@@ -2,13 +2,12 @@
...
@@ -2,13 +2,12 @@
namespace
console\controllers
;
namespace
console\controllers
;
use
common\business\Chain33Business
;
use
common\models\psources\CoinGameBet
;
use
common\service\chain33\Chain33Service
;
use
common\service\exchange\ExchangeBuilderFactory
;
use
common\service\exchange\ExchangeFactory
;
use
yii\console\Controller
;
use
Yii
;
use
Yii
;
use
linslin\yii2\curl\Curl
;
use
yii\console\Controller
;
use
voku\helper\HtmlDomParser
;
use
common\models\psources\CoinSupportedCurrency
;
use
common\service\exchange\ExchangeBuilderFactory
;
class
TickerController
extends
Controller
class
TickerController
extends
Controller
{
{
...
@@ -22,7 +21,7 @@ class TickerController extends Controller
...
@@ -22,7 +21,7 @@ class TickerController extends Controller
$ticker_builder
->
TickerSort
();
$ticker_builder
->
TickerSort
();
});
});
}
}
echo
date
(
'Y-m-d H:i:s'
)
.
'排序更新成功'
.
PHP_EOL
;
echo
date
(
'Y-m-d H:i:s'
)
.
'排序更新成功'
.
PHP_EOL
;
return
0
;
return
0
;
}
}
...
@@ -30,7 +29,36 @@ class TickerController extends Controller
...
@@ -30,7 +29,36 @@ class TickerController extends Controller
{
{
$ticker_builder
=
ExchangeBuilderFactory
::
create
(
'Huobi'
);
$ticker_builder
=
ExchangeBuilderFactory
::
create
(
'Huobi'
);
$ticker_builder
->
hotTickerUpdate
();
$ticker_builder
->
hotTickerUpdate
();
echo
date
(
'Y-m-d H:i:s'
)
.
'更新成功'
.
PHP_EOL
;
echo
date
(
'Y-m-d H:i:s'
)
.
'更新成功'
.
PHP_EOL
;
return
0
;
}
public
function
actionCurrency
()
{
$currency_model
=
CoinSupportedCurrency
::
find
()
->
groupBy
(
'currency_id'
)
->
all
();
$curl
=
new
Curl
();
foreach
(
$currency_model
as
$val
)
{
go
(
function
()
use
(
$val
,
$curl
)
{
\Co
::
sleep
(
0.5
);
$response
=
$curl
->
setPostParams
([
'erectDate'
=>
''
,
'nothing'
=>
''
,
'pjname'
=>
$val
->
currency
->
pj_id
])
->
post
(
'http://srh.bankofchina.com/search/whpj/search.jsp'
);
$response
=
iconv
(
'UTF-8'
,
'GBK//TRANSLIT'
,
$response
);
$html
=
HtmlDomParser
::
str_get_html
(
$response
);
$div
=
(
$html
->
find
(
'div.BOC_main'
));
foreach
(
$div
->
find
(
'td'
)
as
$key
=>
$e
)
{
if
(
$key
==
5
)
{
$key
=
'quotation_boc_'
.
'CNY_'
.
$val
->
currency
->
symbol
;
$currency
=
rtrim
(
sprintf
(
'%.6f'
,
1
/
(
$e
->
innertext
/
100
)),
'0'
);
Yii
::
$app
->
redis_currency
->
hmset
(
$key
,
'low'
,
$currency
,
'high'
,
$currency
,
'last'
,
$currency
,
'open'
,
$currency
);
}
}
});
}
echo
date
(
'Y-m-d H:i:s'
)
.
'计价货币更新成功'
.
PHP_EOL
;
return
0
;
return
0
;
}
}
}
}
\ No newline at end of file
wallet/controllers/WalletController.php
View file @
9a9a1dc7
...
@@ -2,14 +2,13 @@
...
@@ -2,14 +2,13 @@
namespace
wallet\controllers
;
namespace
wallet\controllers
;
use
common\models\psources\CoinCurrency
;
use
common\models\psources\CoinSupportedCurrency
;
use
common\service\trusteeship\TrusteeShipService
;
use
Yii
;
use
Yii
;
use
common\models\Admin
;
use
yii\helpers\ArrayHelper
;
use
wallet\base\BaseController
;
use
wallet\base\BaseController
;
use
common\models\psources\CoinPlatform
;
use
common\models\psources\CoinPlatform
;
use
yii\helpers\ArrayHelper
;
use
common\models\psources\CoinCurrency
;
use
common\models\psources\CoinSupportedCurrency
;
use
common\service\trusteeship\TrusteeShipService
;
class
WalletController
extends
BaseController
class
WalletController
extends
BaseController
{
{
...
@@ -156,14 +155,4 @@ class WalletController extends BaseController
...
@@ -156,14 +155,4 @@ class WalletController extends BaseController
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
}
}
public
function
actionCurrencyUpdate
()
{
$currency_model
=
CoinSupportedCurrency
::
find
()
->
groupBy
(
'currency_id'
)
->
all
();
$pj_id
=
[];
foreach
(
$currency_model
as
$val
)
{
$pj_id
[]
=
$val
->
currency
->
pj_id
;
}
}
}
}
\ 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