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
673ae21f
Commit
673ae21f
authored
Mar 10, 2020
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/optimize' into develop
parents
73b9e091
5f0d6c95
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
89 additions
and
38 deletions
+89
-38
RecommendCoinController.php
api/controllers/RecommendCoinController.php
+56
-35
WalletRecommendCategory.php
common/models/psources/WalletRecommendCategory.php
+25
-0
WalletRecommendCoin.php
common/models/psources/WalletRecommendCoin.php
+3
-2
Chain33Service.php
common/service/chain33/Chain33Service.php
+5
-1
No files found.
api/controllers/RecommendCoinController.php
View file @
673ae21f
...
@@ -2,59 +2,80 @@
...
@@ -2,59 +2,80 @@
namespace
api\controllers
;
namespace
api\controllers
;
use
common\business\ExchangeBusiness
;
use
Yii
;
use
Yii
;
use
api\base\BaseController
;
use
api\base\BaseController
;
use
common\
business\ExchangeBusiness
;
use
common\
models\psources\WalletRecommendCoin
;
use
common\models\psources\
RecommendCoin
;
use
common\models\psources\
WalletRecommendCategory
;
class
RecommendCoinController
extends
BaseController
class
RecommendCoinController
extends
BaseController
{
{
/**
* 获取推荐币种
* @param integer recommend 1首页推介,2次页推介
* @return array
*/
public
function
actionIndex
()
public
function
actionIndex
()
{
{
$recommend
=
Yii
::
$app
->
request
->
post
(
'recommend'
,
0
);
$platform_id
=
$this
->
platform_id
;
$header
=
Yii
::
$app
->
request
->
headers
;
if
(
false
==
$platform_id
)
{
$platform_id
=
$header
[
'FZM-PLATFORM-ID'
]
??
null
;
if
(
false
==
$recommend
||
false
==
$platform_id
)
{
$this
->
code
=
-
1
;
$this
->
code
=
-
1
;
$this
->
msg
=
'参数错误'
;
$this
->
msg
=
'参数错误'
;
goto
doEnd
;
goto
doEnd
;
}
}
$type
=
Yii
::
$app
->
request
->
get
(
'type'
,
1
);
$recommend_coins
=
RecommendCoin
::
find
()
->
where
([
'platform_id'
=>
(
int
)
$platform_id
])
->
orderBy
(
"sort desc"
)
->
all
();
$is_top
=
Yii
::
$app
->
request
->
get
(
'is_top'
,
''
);
if
(
empty
(
$recommend_coins
))
{
if
(
false
==
$is_top
)
{
$recommend_category
=
WalletRecommendCategory
::
find
()
->
select
(
'id, name'
)
->
where
([
'wallet_type'
=>
(
int
)
$type
,
'platform_id'
=>
(
int
)
$platform_id
])
->
andWhere
([
'>'
,
'sort'
,
1
])
->
orderBy
(
'sort'
)
->
asArray
()
->
all
();
}
else
{
$recommend_category
=
WalletRecommendCategory
::
find
()
->
select
(
'id, name'
)
->
where
([
'wallet_type'
=>
(
int
)
$type
,
'platform_id'
=>
(
int
)
$platform_id
,
'sort'
=>
1
])
->
orderBy
(
'sort'
)
->
limit
(
1
)
->
asArray
()
->
all
();
}
if
(
empty
(
$recommend_category
))
{
goto
doEnd
;
goto
doEnd
;
}
}
$this
->
data
=
[];
$ticker
=
[
'low'
=>
0
,
'high'
=>
0
,
'last'
=>
0
,
'open'
=>
0
,
'vol'
=>
0
,
'rmb'
=>
0
,
'usd'
=>
0
];
foreach
(
$recommend_category
as
&
$category
)
{
foreach
(
$recommend_coins
as
$coin
)
{
$name
=
json_decode
(
$category
[
'name'
],
true
);
$recommend_coin_info
=
[
$category
[
'name'
]
=
isset
(
$name
[
$this
->
lang
])
?
$name
[
$this
->
lang
]
:
''
;
'recommend'
=>
$coin
->
recommend
,
'sort'
=>
$coin
->
sort
,
$recommend_coin
=
WalletRecommendCoin
::
find
()
->
where
([
'category_id'
=>
$category
[
'id'
]])
->
all
();
'type'
=>
$coin
->
type
,
$items
=
[];
];
foreach
(
$recommend_coin
as
$coin
)
{
$this
->
data
=
array_merge
(
$this
->
data
,
[
array_merge
(
$coin
->
coin
[
0
],
$recommend_coin_info
)]);
$temp
[
'icon'
]
=
$coin
->
coin
[
'icon'
];
$temp
[
'name'
]
=
$coin
->
coin
[
'name'
];
$temp
[
'platform'
]
=
$coin
->
coin
[
'platform'
];
$temp
[
'chain'
]
=
$coin
->
coin
[
'chain'
];
$temp
[
'treaty'
]
=
$coin
->
coin
[
'treaty'
];
$temp
[
'exchange_id'
]
=
$coin
->
coin
[
'exchange_id'
];
$nickname
=
json_decode
(
$coin
->
coin
[
'nickname'
],
true
);
$temp
[
'nickname'
]
=
isset
(
$nickname
[
$this
->
lang
])
?
$nickname
[
$this
->
lang
]
:
''
;
$introduce
=
json_decode
(
$coin
->
coin
[
'introduce'
],
true
);
$temp
[
'introduce'
]
=
isset
(
$introduce
[
$this
->
lang
])
?
$introduce
[
$this
->
lang
]
:
''
;
array_push
(
$items
,
$temp
);
}
$category
[
'items'
]
=
$items
;
}
}
$chains
=
array_column
(
$this
->
data
,
'chain'
);
if
(
!
empty
(
$is_top
))
{
$symbol
=
array_column
(
$this
->
data
,
'name'
);
$result
=
$recommend_category
[
0
][
'items'
];
$chains_symbols
=
array_keys
(
array_flip
(
$chains
)
+
array_flip
(
$symbol
));
//获取行情信息
$coin_quotations
=
ExchangeBusiness
::
getQuatationByNames
(
$chains_symbols
);
$coin_names
=
array_column
(
$result
,
'name'
);
$coin_names
=
array_merge
(
$coin_names
,
array_column
(
$result
,
'chain'
));
$coin_quotations
=
ExchangeBusiness
::
getQuatationByNames
(
$coin_names
);
$ticker
=
[
'low'
=>
0
,
'high'
=>
0
,
'last'
=>
0
,
'open'
=>
0
,
'vol'
=>
0
,
'rmb'
=>
0
,
'usd'
=>
0
];
$ticker
=
[
'low'
=>
0
,
'high'
=>
0
,
'last'
=>
0
,
'open'
=>
0
,
'vol'
=>
0
,
'rmb'
=>
0
,
'usd'
=>
0
];
foreach
(
$this
->
data
as
$key
=>
&
$val
)
{
foreach
(
$result
as
$key
=>
&
$val
)
{
$val
[
'chain_quotation'
]
=
isset
(
$coin_quotations
[
strtoupper
(
$val
[
'chain'
])])
?
$coin_quotations
[
strtoupper
(
$val
[
'chain'
])]
:
[];
$val
[
'chain_quotation'
]
=
isset
(
$coin_quotations
[
strtoupper
(
$val
[
'chain'
])])
?
$coin_quotations
[
strtoupper
(
$val
[
'chain'
])]
:
[];
$nickname
=
json_decode
(
$val
[
'nickname'
],
true
);
$result
[
$key
]
=
array_merge
(
$val
,
isset
(
$coin_quotations
[
strtoupper
(
$val
[
'name'
])])
?
$coin_quotations
[
strtoupper
(
$val
[
'name'
])]
:
$ticker
);
$val
[
'nickname'
]
=
isset
(
$nickname
[
$this
->
lang
])
?
$nickname
[
$this
->
lang
]
:
''
;
$val
[
'chain_rmb'
]
=
isset
(
$val
[
'chain_quotation'
][
'rmb'
])
?
$val
[
'chain_quotation'
][
'rmb'
]
:
0
;
$introduce
=
json_decode
(
$val
[
'introduce'
],
true
);
$val
[
'chain_usd'
]
=
isset
(
$val
[
'chain_quotation'
][
'usd'
])
?
$val
[
'chain_quotation'
][
'usd'
]
:
0
;
$val
[
'introduce'
]
=
isset
(
$introduce
[
$this
->
lang
])
?
$introduce
[
$this
->
lang
]
:
''
;
}
$this
->
data
[
$key
]
=
array_merge
(
$val
,
isset
(
$coin_quotations
[
strtoupper
(
$val
[
'name'
])])
?
$coin_quotations
[
strtoupper
(
$val
[
'name'
])]
:
$ticker
);
$this
->
data
=
$result
;
goto
doEnd
;
}
}
$this
->
data
=
$recommend_category
;
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/WalletRecommendCategory.php
0 → 100644
View file @
673ae21f
<?php
namespace
common\models\psources
;
use
Yii
;
use
common\core\BaseActiveRecord
;
class
WalletRecommendCategory
extends
BaseActiveRecord
{
public
static
function
getDb
()
{
return
Yii
::
$app
->
get
(
'p_sources'
);
}
public
static
function
tableName
()
{
return
'{{wallet_recommend_category}}'
;
}
public
function
getRecommendCoin
()
{
return
$this
->
hasMany
(
WalletRecommendCoin
::
className
(),
[
'category_id'
=>
'id'
])
->
asArray
()
->
all
();
}
}
\ No newline at end of file
common/models/psources/RecommendCoin.php
→
common/models/psources/
Wallet
RecommendCoin.php
View file @
673ae21f
...
@@ -5,7 +5,7 @@ namespace common\models\psources;
...
@@ -5,7 +5,7 @@ namespace common\models\psources;
use
Yii
;
use
Yii
;
use
common\core\BaseActiveRecord
;
use
common\core\BaseActiveRecord
;
class
RecommendCoin
extends
BaseActiveRecord
class
Wallet
RecommendCoin
extends
BaseActiveRecord
{
{
public
static
function
getDb
()
public
static
function
getDb
()
{
{
...
@@ -19,6 +19,6 @@ class RecommendCoin extends BaseActiveRecord
...
@@ -19,6 +19,6 @@ class RecommendCoin extends BaseActiveRecord
public
function
getCoin
()
public
function
getCoin
()
{
{
return
$this
->
hasOne
(
WalletCoin
::
className
(),
[
'id'
=>
'cid'
])
->
select
([
'id'
,
'
sid'
,
'icon'
,
'name'
,
'introduce'
,
'nickname'
,
'platform'
,
'chain'
,
'treaty'
,
'exchange_id'
])
->
asArray
()
->
all
();
return
$this
->
hasOne
(
WalletCoin
::
className
(),
[
'id'
=>
'cid'
])
->
select
([
'id'
,
'
icon'
,
'name'
,
'introduce'
,
'nickname'
,
'platform'
,
'chain'
,
'treaty'
,
'exchange_id'
])
->
asArray
();
}
}
}
}
\ No newline at end of file
common/service/chain33/Chain33Service.php
View file @
673ae21f
...
@@ -231,7 +231,11 @@ class Chain33Service
...
@@ -231,7 +231,11 @@ class Chain33Service
$params
=
[
$params
=
[
'data'
=>
$data
'data'
=>
$data
];
];
return
$this
->
send
(
$params
,
'Chain33.SendTransaction'
);
$timeout
=
[
'connect_timeout'
=>
50000
,
'timeout_ms'
=>
50000
];
return
$this
->
send
(
$params
,
'Chain33.SendTransaction'
,
$timeout
);
}
}
public
function
QueryTransaction
(
$data
)
public
function
QueryTransaction
(
$data
)
...
...
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