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
2456f93b
Commit
2456f93b
authored
Nov 02, 2020
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/optimize' into develop
parents
28ce08f8
2b8654fb
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
104 additions
and
20 deletions
+104
-20
RecommendCoinController.php
api/controllers/RecommendCoinController.php
+71
-0
WalletCoinController.php
api/controllers/WalletCoinController.php
+2
-2
ExchangeBusiness.php
common/business/ExchangeBusiness.php
+11
-5
WalletRecommendCoin.php
common/models/psources/WalletRecommendCoin.php
+5
-4
Jinwang.php
common/service/exchange/Jinwang.php
+1
-1
JinwangBuilder.php
common/service/exchange/factory/JinwangBuilder.php
+1
-1
CrossChainController.php
console/controllers/CrossChainController.php
+4
-1
IpExceptionController.php
console/controllers/IpExceptionController.php
+9
-6
No files found.
api/controllers/RecommendCoinController.php
View file @
2456f93b
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
namespace
api\controllers
;
namespace
api\controllers
;
use
common\business\ExchangeBusiness
;
use
common\business\ExchangeBusiness
;
use
common\models\psources\Coin
;
use
common\models\psources\CoinSupportedChain
;
use
common\models\psources\CoinSupportedChain
;
use
Yii
;
use
Yii
;
use
api\base\BaseController
;
use
api\base\BaseController
;
...
@@ -122,4 +123,73 @@ class RecommendCoinController extends BaseController
...
@@ -122,4 +123,73 @@ class RecommendCoinController extends BaseController
doEnd
:
doEnd
:
return
[
'code'
=>
$this
->
code
,
'data'
=>
$this
->
data
,
'msg'
=>
$this
->
msg
];
return
[
'code'
=>
$this
->
code
,
'data'
=>
$this
->
data
,
'msg'
=>
$this
->
msg
];
}
}
public
function
actionTrusteeship
()
{
$platform_id
=
$this
->
platform_id
;
if
(
false
==
$platform_id
)
{
$this
->
code
=
-
1
;
$this
->
msg
=
'参数错误'
;
goto
doEnd
;
}
$coin_trusteeship
=
WalletRecommendCoin
::
find
()
->
select
(
'cid'
)
->
where
([
'type'
=>
WalletRecommendCoin
::
TYPE_TRUSTEESHIP
,
'platform_id'
=>
$platform_id
])
->
asArray
()
->
all
();
$select
=
[
'id'
,
'sid'
,
'icon'
,
'name'
,
'introduce'
,
'optional_name'
,
'nickname'
,
'platform'
,
'chain'
,
'treaty'
];
$coin_ids
=
array_column
(
$coin_trusteeship
,
'cid'
);
if
(
false
==
$coin_ids
)
{
$this
->
code
=
1
;
$this
->
msg
=
'数据为空'
;
goto
doEnd
;
}
$coin_infos
=
Coin
::
getCoinInfoByIds
(
$coin_ids
,
$select
,
'id'
);
foreach
(
$coin_infos
as
$key
=>
&
$val
)
{
$nickname
=
json_decode
(
$val
[
'nickname'
],
true
);
$val
[
'nickname'
]
=
isset
(
$nickname
[
$this
->
lang
])
?
$nickname
[
$this
->
lang
]
:
''
;
$introduce
=
json_decode
(
$val
[
'introduce'
],
true
);
$val
[
'introduce'
]
=
isset
(
$introduce
[
$this
->
lang
])
?
$introduce
[
$this
->
lang
]
:
''
;
}
//获取行情信息
$coin_names
=
array_column
(
$coin_infos
,
'name'
);
$coin_names
=
array_merge
(
$coin_names
,
array_column
(
$coin_infos
,
'chain'
));
$coin_quotations
=
ExchangeBusiness
::
getQuatationByNames
(
$coin_names
);
if
(
$coin_infos
)
{
array_shift
(
$select
);
foreach
(
$coin_trusteeship
as
$key
=>
&
$value
)
{
$temp_key
=
$coin_infos
[
$value
[
'cid'
]][
'name'
];
foreach
(
$select
as
$item
)
{
$value
[
$item
]
=
$coin_infos
[
$value
[
'cid'
]][
$item
];
if
(
$platform_id
!=
2
)
{
//国盾币不需要行情
$value
[
'low'
]
=
$coin_quotations
[
$temp_key
][
'low'
];
$value
[
'high'
]
=
$coin_quotations
[
$temp_key
][
'high'
];
$value
[
'last'
]
=
$coin_quotations
[
$temp_key
][
'last'
];
$value
[
'rmb'
]
=
$coin_quotations
[
$temp_key
][
'rmb'
];
$value
[
'usd'
]
=
$coin_quotations
[
$temp_key
][
'usd'
]
??
0
;
}
else
{
$value
[
'low'
]
=
0
;
$value
[
'high'
]
=
0
;
$value
[
'last'
]
=
0
;
$value
[
'rmb'
]
=
0
;
$value
[
'usd'
]
=
0
;
}
}
$value
[
'id'
]
=
$value
[
'cid'
];
$value
[
'sid'
]
=
ucfirst
(
$value
[
'sid'
]);
$value
[
'chain_quotation'
]
=
$coin_quotations
[
$coin_infos
[
$value
[
'cid'
]][
'chain'
]];
$value
[
'chain_rmb'
]
=
isset
(
$coin_quotations
[
$coin_infos
[
$value
[
'cid'
]][
'chain'
]][
'rmb'
])
?
$coin_quotations
[
$coin_infos
[
$value
[
'cid'
]][
'chain'
]][
'rmb'
]
:
0
;
$value
[
'chain_usd'
]
=
isset
(
$coin_quotations
[
$coin_infos
[
$value
[
'cid'
]][
'chain'
]][
'usd'
])
?
$coin_quotations
[
$coin_infos
[
$value
[
'cid'
]][
'chain'
]][
'usd'
]
:
0
;
unset
(
$value
[
'create_time'
],
$value
[
'update_time'
],
$value
[
'cid'
]);
$value
[
'type'
]
=
WalletRecommendCoin
::
TYPE_TRUSTEESHIP
;
$value
[
'platform_id'
]
=
$platform_id
;
$value
[
'sort'
]
=
$value
[
'recommend'
]
=
1
;
$value
[
'coin'
]
=
$value
[
'name'
];
}
unset
(
$key
,
$value
);
}
$this
->
data
=
$coin_trusteeship
;
doEnd
:
return
[
'code'
=>
$this
->
code
,
'data'
=>
$this
->
data
,
'msg'
=>
$this
->
msg
,
'count'
=>
count
(
$this
->
data
)];
}
}
}
\ No newline at end of file
api/controllers/WalletCoinController.php
View file @
2456f93b
...
@@ -49,7 +49,7 @@ class WalletCoinController extends BaseController
...
@@ -49,7 +49,7 @@ class WalletCoinController extends BaseController
foreach
(
$condition
as
$val
)
{
foreach
(
$condition
as
$val
)
{
if
(
is_array
(
$val
))
{
if
(
is_array
(
$val
))
{
$model
=
WalletCoin
::
find
()
->
select
(
'id,icon,name,nickname,introduce,platform,chain,address as contract_address,treaty'
)
$model
=
WalletCoin
::
find
()
->
select
(
'id,icon,name,nickname,
optional_name,
introduce,platform,chain,address as contract_address,treaty'
)
->
where
([
'name'
=>
$val
[
0
],
'platform'
=>
$val
[
1
]])
->
where
([
'name'
=>
$val
[
0
],
'platform'
=>
$val
[
1
]])
->
andWhere
([
'>'
,
"find_in_set(
$platform_id
, platform_id)"
,
0
])
->
andWhere
([
'>'
,
"find_in_set(
$platform_id
, platform_id)"
,
0
])
->
asArray
()
->
asArray
()
...
@@ -57,7 +57,7 @@ class WalletCoinController extends BaseController
...
@@ -57,7 +57,7 @@ class WalletCoinController extends BaseController
}
}
if
(
is_string
(
$val
))
{
if
(
is_string
(
$val
))
{
$model
=
WalletCoin
::
find
()
->
select
(
'id,icon,name,nickname,introduce,platform,chain,address as contract_address,treaty'
)
$model
=
WalletCoin
::
find
()
->
select
(
'id,icon,name,nickname,
optional_name,
introduce,platform,chain,address as contract_address,treaty'
)
->
where
([
'name'
=>
$val
])
->
where
([
'name'
=>
$val
])
->
andWhere
([
'>'
,
"find_in_set(
$platform_id
, platform_id)"
,
0
])
->
andWhere
([
'>'
,
"find_in_set(
$platform_id
, platform_id)"
,
0
])
->
asArray
()
->
asArray
()
...
...
common/business/ExchangeBusiness.php
View file @
2456f93b
...
@@ -142,10 +142,10 @@ class ExchangeBusiness
...
@@ -142,10 +142,10 @@ class ExchangeBusiness
if
(
strtoupper
(
$tag
)
==
'POKE'
)
{
if
(
strtoupper
(
$tag
)
==
'POKE'
)
{
$quotation
=
[
$quotation
=
[
'low'
=>
0.1
59
1
,
'low'
=>
0.1
60
1
,
'high'
=>
0.1
59
1
,
'high'
=>
0.1
60
1
,
'last'
=>
0.1
59
1
,
'last'
=>
0.1
60
1
,
'rmb'
=>
0.1
59
1
,
'rmb'
=>
0.1
60
1
,
];
];
goto
doEnd
;
goto
doEnd
;
}
}
...
@@ -175,6 +175,12 @@ class ExchangeBusiness
...
@@ -175,6 +175,12 @@ class ExchangeBusiness
}
}
$f
=
false
;
$f
=
false
;
$quotation
=
[];
$quotation
=
[];
if
(
in_array
(
strtoupper
(
$tag
),
[
'GLCW'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Jinwang"
);
$quotation
=
$exchange
->
getTicker
(
$tag
,
'USDT'
);
goto
doEnd
;
}
if
(
in_array
(
strtoupper
(
$tag
),
[
'SUM'
,
'USDW'
,
'FUT'
]))
{
if
(
in_array
(
strtoupper
(
$tag
),
[
'SUM'
,
'USDW'
,
'FUT'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Isummit"
);
$exchange
=
ExchangeFactory
::
createExchange
(
"Isummit"
);
$quotation
=
$exchange
->
getTicker
(
$tag
,
'USDT'
);
$quotation
=
$exchange
->
getTicker
(
$tag
,
'USDT'
);
...
@@ -390,7 +396,7 @@ class ExchangeBusiness
...
@@ -390,7 +396,7 @@ class ExchangeBusiness
$exchange
=
ExchangeFactory
::
createExchange
(
"Go"
);
$exchange
=
ExchangeFactory
::
createExchange
(
"Go"
);
$rate
=
$exchange
->
getTicker
(
"CNY"
,
"USD"
);
$rate
=
$exchange
->
getTicker
(
"CNY"
,
"USD"
);
$cny_usd_rate
=
1
/
$rate
[
'last'
];
$cny_usd_rate
=
1
/
$rate
[
'last'
];
if
(
in_array
(
strtoupper
(
$tag
),
[
'FOLI'
,
'CIC'
,
'KPC8'
,
'BVA'
,
'DAG'
,
'BNC'
,
'GHP'
,
'DRA'
,
'ETC'
,
'PAX'
,
'STH'
,
'XJH'
,
'SFT'
,
'TSC'
,
'SUM'
,
'USDW'
,
'FUT'
,
'MBTC'
,
'METH'
]))
{
if
(
in_array
(
strtoupper
(
$tag
),
[
'FOLI'
,
'CIC'
,
'KPC8'
,
'BVA'
,
'DAG'
,
'BNC'
,
'GHP'
,
'DRA'
,
'ETC'
,
'PAX'
,
'STH'
,
'XJH'
,
'SFT'
,
'TSC'
,
'SUM'
,
'USDW'
,
'FUT'
,
'MBTC'
,
'METH'
,
'GLCW'
]))
{
$quotation
[
'usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'last'
]);
$quotation
[
'usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'last'
]);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'last'
]
/
$cny_usd_rate
);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'last'
]
/
$cny_usd_rate
);
$quotation
[
'low'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'low'
]);
$quotation
[
'low'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'low'
]);
...
...
common/models/psources/WalletRecommendCoin.php
View file @
2456f93b
...
@@ -7,6 +7,9 @@ use common\core\BaseActiveRecord;
...
@@ -7,6 +7,9 @@ use common\core\BaseActiveRecord;
class
WalletRecommendCoin
extends
BaseActiveRecord
class
WalletRecommendCoin
extends
BaseActiveRecord
{
{
const
TYPE_COMMON
=
1
;
//去中心化
const
TYPE_TRUSTEESHIP
=
2
;
//托管钱包
public
static
function
getDb
()
public
static
function
getDb
()
{
{
return
Yii
::
$app
->
get
(
'p_sources'
);
return
Yii
::
$app
->
get
(
'p_sources'
);
...
@@ -17,8 +20,5 @@ class WalletRecommendCoin extends BaseActiveRecord
...
@@ -17,8 +20,5 @@ class WalletRecommendCoin extends BaseActiveRecord
return
'{{wallet_recommend_coin}}'
;
return
'{{wallet_recommend_coin}}'
;
}
}
public
function
getCoin
()
{
return
$this
->
hasOne
(
Coin
::
className
(),
[
'id'
=>
'cid'
])
->
select
([
'id'
,
'icon'
,
'name'
,
'introduce'
,
'nickname'
,
'platform'
,
'chain'
,
'treaty'
])
->
asArray
();
}
}
}
\ No newline at end of file
common/service/exchange/Jinwang.php
View file @
2456f93b
...
@@ -34,7 +34,7 @@ class Jinwang extends Exchange implements ExchangeInterface
...
@@ -34,7 +34,7 @@ class Jinwang extends Exchange implements ExchangeInterface
*/
*/
public
function
formatSymbol
(
$tag
=
'TG'
,
$aim
=
'USDT'
)
public
function
formatSymbol
(
$tag
=
'TG'
,
$aim
=
'USDT'
)
{
{
return
strto
upper
(
$tag
.
$aim
);
return
strto
lower
(
$tag
.
'_'
.
$aim
);
}
}
/**
/**
...
...
common/service/exchange/factory/JinwangBuilder.php
View file @
2456f93b
...
@@ -34,7 +34,7 @@ class JinwangBuilder extends FactoryService
...
@@ -34,7 +34,7 @@ class JinwangBuilder extends FactoryService
$keys
=
$this
->
redis
->
smembers
(
$this
->
supported_symbol
);
$keys
=
$this
->
redis
->
smembers
(
$this
->
supported_symbol
);
if
(
false
==
$this
->
redis
->
exists
(
$this
->
supported_symbol_list
))
{
if
(
false
==
$this
->
redis
->
exists
(
$this
->
supported_symbol_list
))
{
foreach
(
$keys
as
$val
)
{
foreach
(
$keys
as
$val
)
{
if
(
in_array
(
strtoupper
(
$val
),
[
'LTC_USDT'
,
'BTC_USDT'
,
'EOS_USDT'
,
'TG_USDT'
,
'TPC_USDT'
,
'ETH_USDT'
]))
{
if
(
in_array
(
strtoupper
(
$val
),
[
'LTC_USDT'
,
'BTC_USDT'
,
'EOS_USDT'
,
'TG_USDT'
,
'TPC_USDT'
,
'ETH_USDT'
,
'GLCW_USDT'
]))
{
$this
->
redis
->
lpush
(
$this
->
supported_symbol_list
,
strtoupper
(
$val
));
$this
->
redis
->
lpush
(
$this
->
supported_symbol_list
,
strtoupper
(
$val
));
}
}
}
}
...
...
console/controllers/CrossChainController.php
View file @
2456f93b
...
@@ -110,7 +110,10 @@ class CrossChainController extends Controller
...
@@ -110,7 +110,10 @@ class CrossChainController extends Controller
// 'port' => 8801
// 'port' => 8801
// ];
// ];
$service
=
new
Chain33Service
(
$node_params
);
$service
=
new
Chain33Service
(
$node_params
);
$result
=
$service
->
getHeight
();
$payload
=
[
"data"
=>
'user.p.game'
,
];
$result
=
$service
->
chainQuery
(
'paracross'
,
'GetHeight'
,
$payload
);
$consensHeight
=
$result
[
'result'
][
'consensHeight'
];
$consensHeight
=
$result
[
'result'
][
'consensHeight'
];
$current_time
=
time
();
$current_time
=
time
();
...
...
console/controllers/IpExceptionController.php
View file @
2456f93b
...
@@ -65,7 +65,7 @@ class IpExceptionController extends Controller
...
@@ -65,7 +65,7 @@ class IpExceptionController extends Controller
return
false
;
return
false
;
}
}
$redis_ticker
=
\Yii
::
$app
->
redis_es
;
//
$redis_ticker = \Yii::$app->redis_es;
$limit
=
\Yii
::
$app
->
params
[
'api_ip_limit'
][
'limit'
];
$limit
=
\Yii
::
$app
->
params
[
'api_ip_limit'
][
'limit'
];
$white_list
=
\Yii
::
$app
->
params
[
'api_ip_limit'
][
'white_list'
];
$white_list
=
\Yii
::
$app
->
params
[
'api_ip_limit'
][
'white_list'
];
$ips
=
''
;
$ips
=
''
;
...
@@ -73,14 +73,17 @@ class IpExceptionController extends Controller
...
@@ -73,14 +73,17 @@ class IpExceptionController extends Controller
if
(
in_array
(
$val
[
'key'
],
$white_list
))
continue
;
if
(
in_array
(
$val
[
'key'
],
$white_list
))
continue
;
if
(
!
isset
(
$val
[
'request'
][
'buckets'
]))
continue
;
if
(
!
isset
(
$val
[
'request'
][
'buckets'
]))
continue
;
foreach
(
$val
[
'request'
][
'buckets'
]
as
$b
=>
$item
)
{
foreach
(
$val
[
'request'
][
'buckets'
]
as
$b
=>
$item
)
{
if
(
strpos
(
$item
[
'key'
],
'/interface/ticker/hot-ticker'
)
!==
false
)
{
if
(
$item
[
'doc_count'
]
>
$limit
)
{
if
(
$item
[
'doc_count'
]
>
$limit
)
{
foreach
(
$val
[
'request'
][
'buckets'
]
as
$bucket
)
{
$redis_ticker
->
hmset
(
$val
[
'key'
],
$bucket
[
'key'
],
$bucket
[
'doc_count'
]);
}
$ips
.=
$val
[
'key'
]
.
','
;
$ips
.=
$val
[
'key'
]
.
','
;
}
}
}
// if (strpos($item['key'],'/interface/ticker/hot-ticker') !== false) {
// if ($item['doc_count'] > $limit) {
// foreach ($val['request']['buckets'] as $bucket) {
// $redis_ticker->hmset($val['key'], $bucket['key'], $bucket['doc_count']);
// }
// $ips .= $val['key'] . ',';
// }
// }
}
}
}
}
...
...
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