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
c63168a3
Commit
c63168a3
authored
Dec 06, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into feature/es
parents
956ecc5d
45644b4f
Show whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
1134 additions
and
230 deletions
+1134
-230
CoinController.php
api/controllers/CoinController.php
+9
-5
MarketController.php
api/controllers/MarketController.php
+34
-0
NoticeController.php
api/controllers/NoticeController.php
+67
-36
OrderController.php
api/controllers/OrderController.php
+192
-0
SupportedSymbolController.php
api/controllers/SupportedSymbolController.php
+70
-6
TickerController.php
api/controllers/TickerController.php
+5
-1
WalletController.php
api/controllers/WalletController.php
+10
-3
CoinSupportedSymbolController.php
backend/controllers/CoinSupportedSymbolController.php
+21
-22
CoinSupportedSymbolForm.php
backend/models/coin/CoinSupportedSymbolForm.php
+16
-23
add.php
backend/views/coin-supported-symbol/add.php
+10
-18
edit.php
backend/views/coin-supported-symbol/edit.php
+0
-65
index.php
backend/views/coin-supported-symbol/index.php
+3
-5
index.php
backend/views/wallet/index.php
+2
-1
index.js
backend/web/js/coin-supported-symbol/index.js
+50
-4
ExchangeBusiness.php
common/business/ExchangeBusiness.php
+30
-17
CoinCTocTransfer.php
common/models/psources/CoinCTocTransfer.php
+52
-0
CoinIssueCoin.php
common/models/psources/CoinIssueCoin.php
+9
-3
CoinSupportedSymbol.php
common/models/psources/CoinSupportedSymbol.php
+18
-2
Notice.php
common/models/pwallet/Notice.php
+71
-0
Chain33Service.php
common/service/chain33/Chain33Service.php
+1
-1
Boc.php
common/service/exchange/Boc.php
+10
-6
Draex.php
common/service/exchange/Draex.php
+58
-0
Zhaobi.php
common/service/exchange/Zhaobi.php
+2
-10
ZhaobiBuilder.php
common/service/exchange/factory/ZhaobiBuilder.php
+16
-0
OrderController.php
console/controllers/OrderController.php
+210
-0
TickerController.php
console/controllers/TickerController.php
+13
-1
IssueChainController.php
wallet/controllers/IssueChainController.php
+1
-1
NoticeController.php
wallet/controllers/NoticeController.php
+154
-0
No files found.
api/controllers/CoinController.php
View file @
c63168a3
...
@@ -245,11 +245,15 @@ class CoinController extends BaseController
...
@@ -245,11 +245,15 @@ 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
);
}
}
$last
[]
=
1
;
$currency
=
CoinCurrency
::
find
()
->
where
([
'pj_id'
=>
$this
->
currency_id
])
->
one
();
$currency
=
CoinCurrency
::
find
()
->
where
([
'pj_id'
=>
$this
->
currency_id
])
->
one
();
if
(
false
!=
$currency
)
{
if
(
false
!=
$currency
)
{
if
(
1111
==
$this
->
currency_id
)
{
$last
[]
=
1
;
}
else
{
$last
=
Yii
::
$app
->
redis_currency
->
hmget
(
'quotation_boc_'
.
'CNY_'
.
$currency
->
symbol
,
'last'
);
$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
;
...
@@ -260,8 +264,8 @@ class CoinController extends BaseController
...
@@ -260,8 +264,8 @@ 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['chain_country_rate'] = (float)sprintf("%0.4f", $last[0] * $value['chain_rmb']);
$value
[
'chain_country_rate'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$last
[
0
]
*
$value
[
'chain_rmb'
]);
$value
[
'country_rate'
]
=
(
false
==
$currency
)
?
$value
[
'
chain_
rmb'
]
:
(
float
)
sprintf
(
"%0.4f"
,
$last
[
0
]
*
$value
[
'rmb'
]);
$value
[
'country_rate'
]
=
(
false
==
$currency
)
?
$value
[
'rmb'
]
:
(
float
)
sprintf
(
"%0.4f"
,
$last
[
0
]
*
$value
[
'rmb'
]);
}
}
return
$result
;
return
$result
;
}
}
...
@@ -287,7 +291,7 @@ class CoinController extends BaseController
...
@@ -287,7 +291,7 @@ class CoinController extends BaseController
$query
=
Coin
::
find
()
$query
=
Coin
::
find
()
->
select
(
'id, sid, icon, name, optional_name, nickname, platform, chain, address as contract_address, treaty'
)
->
select
(
'id, sid, icon, name, optional_name, nickname, platform, chain, address as contract_address, treaty'
)
->
where
([
'
platform_id'
=>
(
int
)
$platform_id
])
->
where
([
'
>'
,
"find_in_set(
$platform_id
, platform_id)"
,
0
])
->
orderBy
(
'id'
);
->
orderBy
(
'id'
);
if
(
false
!=
$chain
)
{
if
(
false
!=
$chain
)
{
...
@@ -299,7 +303,7 @@ class CoinController extends BaseController
...
@@ -299,7 +303,7 @@ class CoinController extends BaseController
}
}
if
(
false
!=
$keyword
)
{
if
(
false
!=
$keyword
)
{
$query
->
andWhere
([
'or'
,
[
'like'
,
'address'
,
$keyword
],
[
'like'
,
'name'
,
$keyword
]
,
[
'like'
,
'nickname'
,
$keyword
]
]);
$query
->
andWhere
([
'or'
,
[
'like'
,
'address'
,
$keyword
],
[
'like'
,
'name'
,
$keyword
]]);
}
}
$data
=
$query
->
offset
((
$page
-
1
)
*
$limit
)
->
limit
(
$limit
)
->
asArray
()
->
all
();
$data
=
$query
->
offset
((
$page
-
1
)
*
$limit
)
->
limit
(
$limit
)
->
asArray
()
->
all
();
...
...
api/controllers/MarketController.php
0 → 100644
View file @
c63168a3
<?php
namespace
api\controllers
;
use
Yii
;
use
api\base\BaseController
;
use
common\service\exchange\ExchangeBuilderFactory
;
class
MarketController
extends
BaseController
{
public
function
actionDetail
()
{
$symbol
=
Yii
::
$app
->
request
->
get
(
'symbol'
,
''
);
if
(
false
==
$symbol
)
{
$msg
=
'invalid symbol'
;
$code
=
-
1
;
goto
doEnd
;
}
$builder
=
ExchangeBuilderFactory
::
create
(
'Zhaobi'
);
$result
=
$builder
->
getDetail
(
$symbol
);
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/NoticeController.php
View file @
c63168a3
...
@@ -12,6 +12,7 @@ use common\service\exchange\ExchangeBuilderFactory;
...
@@ -12,6 +12,7 @@ use common\service\exchange\ExchangeBuilderFactory;
use
Yii
;
use
Yii
;
use
api\base\BaseController
;
use
api\base\BaseController
;
use
common\models\pwallet\Notice
;
use
common\models\pwallet\Notice
;
use
yii\data\Pagination
;
/**
/**
* 公告控制器
* 公告控制器
...
@@ -21,50 +22,80 @@ use common\models\pwallet\Notice;
...
@@ -21,50 +22,80 @@ use common\models\pwallet\Notice;
class
NoticeController
extends
BaseController
class
NoticeController
extends
BaseController
{
{
/**
/**
* 返回公告列表
* 申请列表
*
* @param integer page
* @var $page
* @param integer size
* @var $limit
* @var $condition 筛选条件
* @return array
* @return array
*/
*/
public
function
actionList
()
public
function
actionList
()
{
{
$request
=
Yii
::
$app
->
request
;
$data
=
null
;
$page
=
$request
->
post
(
'page'
,
1
);
$header
=
Yii
::
$app
->
request
->
headers
;
$limit
=
$request
->
post
(
'limit'
,
10
);
$platform_id
=
$header
[
'FZM-PLATFORM-ID'
]
??
null
;
$post
=
$request
->
post
();
$type
=
Yii
::
$app
->
request
->
get
(
'type'
,
''
);
$condition
=
[];
if
(
empty
(
$platform_id
))
{
$post
=
array_filter
(
$post
,
function
(
$value
,
$key
)
{
$msg
=
'缺少必要的参数'
;
if
(
$key
==
'status'
&&
is_numeric
(
$value
))
{
$code
=
-
1
;
return
true
;
goto
doEnd
;
}
if
(
$key
==
'id'
&&
is_numeric
(
$value
))
{
return
true
;
}
return
$value
;
},
ARRAY_FILTER_USE_BOTH
);
if
(
isset
(
$post
[
'id'
]))
{
$condition
[]
=
[
'id'
=>
$post
[
'id'
]];
}
if
(
isset
(
$post
[
'title'
]))
{
$condition
[]
=
[
'like'
,
'title'
,
$post
[
'title'
]];
}
if
(
isset
(
$post
[
'author'
]))
{
$condition
[]
=
[
'author'
=>
$post
[
'author'
]];
}
}
if
(
isset
(
$post
[
'status'
]))
{
$condition
[]
=
[
'status'
=>
$post
[
'status'
]];
$page
=
\Yii
::
$app
->
request
->
get
(
'page'
,
1
);
$size
=
\Yii
::
$app
->
request
->
get
(
'size'
,
10
);
$query
=
Notice
::
find
()
->
select
(
'id, title, content, author, type, is_top, create_time'
)
->
where
([
'status'
=>
Notice
::
STATUS_ON
])
->
orderBy
(
'create_time desc'
);
if
(
false
!=
$type
)
{
$query
->
andWhere
([
'type'
=>
(
int
)
$type
]);
}
}
if
(
isset
(
$post
[
'create_at'
]))
{
$condition
[]
=
[
'>='
,
'create_at'
,
$post
[
'create_at'
]];
$countQuery
=
clone
$query
;
$models
=
$query
->
offset
((
$page
-
1
)
*
$size
)
->
limit
(
$size
)
->
all
();
$pages
=
new
Pagination
([
'totalCount'
=>
$countQuery
->
count
(),
'pageSize'
=>
$size
]);
$data
=
[
'list'
=>
$models
,
'page'
=>
[
'pageCount'
=>
$pages
->
pageCount
,
'pageSize'
=>
(
int
)
$size
,
'currentPage'
=>
(
int
)
$page
,
]
];
$msg
=
'ok'
;
$code
=
0
;
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
}
}
if
(
isset
(
$post
[
'update_at'
]))
{
$condition
[]
=
[
'>='
,
'update_at'
,
$post
[
'update_at'
]];
/**
* 申请列表
* @param integer page
* @param integer size
* @return array
*/
public
function
actionDetail
()
{
$data
=
null
;
$header
=
Yii
::
$app
->
request
->
headers
;
$platform_id
=
$header
[
'FZM-PLATFORM-ID'
]
??
null
;
$id
=
Yii
::
$app
->
request
->
get
(
'id'
,
0
);
if
(
empty
(
$platform_id
)
||
empty
(
$id
))
{
$msg
=
'缺少必要的参数'
;
$code
=
-
1
;
goto
doEnd
;
}
}
$data
=
Notice
::
getList
(
$page
,
$limit
,
$condition
);
return
$data
;
$data
=
Notice
::
find
()
->
select
(
'title,content,author,type,create_time'
)
->
where
([
'id'
=>
$id
,
'platform_id'
=>
$platform_id
])
->
asArray
()
->
one
();
$msg
=
'ok'
;
$code
=
0
;
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
}
}
public
function
actionIndex
()
public
function
actionIndex
()
...
...
api/controllers/OrderController.php
0 → 100644
View file @
c63168a3
<?php
namespace
api\controllers
;
use
Yii
;
use
yii\data\Pagination
;
use
api\base\BaseController
;
use
common\models\psources\CoinCTocTransfer
;
class
OrderController
extends
BaseController
{
public
function
actionIndex
()
{
$code
=
-
1
;
$request
=
Yii
::
$app
->
request
;
if
(
!
$request
->
isPost
)
{
$msg
=
'请求错误!'
;
goto
doEnd
;
}
$post
=
$request
->
post
();
$data
[
'is_sell'
]
=
(
false
==
$post
[
'isSell'
])
?
0
:
1
;
$data
[
'type'
]
=
$post
[
'type'
];
$data
[
'address'
]
=
$post
[
'address'
];
$data
[
'token_name'
]
=
strtoupper
(
$post
[
'token_name'
]);
$data
[
'market_name'
]
=
strtoupper
(
$post
[
'market_name'
]);
$data
[
'price'
]
=
$post
[
'price'
];
$data
[
'amount'
]
=
$post
[
'amount'
];
$data
[
'transfer_number'
]
=
date
(
'YmdHis'
)
.
self
::
getrandnums
();
$redis
=
Yii
::
$app
->
redis_app
;
$key
=
'C2C_'
.
$data
[
'is_sell'
]
.
'_'
.
str_replace
(
'/'
,
''
,
strtoupper
(
$post
[
'token_name'
]))
.
'_'
.
str_replace
(
'/'
,
''
,
strtoupper
(
$post
[
'market_name'
]));
if
(
$redis
->
hexists
(
$key
,
$data
[
'address'
]))
{
$msg
=
'尚存在一笔未完成的交易!'
;
goto
doEnd
;
}
if
(
!
$redis
->
exists
(
$key
))
{
$redis
->
hmset
(
$key
,
$data
[
'address'
],
time
());
}
foreach
(
$post
[
'txs'
]
as
$key
=>
$val
)
{
$model
=
new
CoinCTocTransfer
();
$data
[
'txhex'
]
=
$val
[
'tx'
];
$data
[
'transfer_url'
]
=
$val
[
'url'
];
$data
[
'step'
]
=
$val
[
'step'
];
$data
[
'consensus'
]
=
(
false
==
$val
[
'consensus'
])
?
0
:
1
;
$model
->
load
(
$data
,
''
);
$model
->
save
();
}
$code
=
0
;
$msg
=
'success'
;
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
];
}
public
function
actionOrderList
()
{
$address
=
Yii
::
$app
->
request
->
get
(
'address'
,
''
);
$is_sell
=
Yii
::
$app
->
request
->
get
(
'isSell'
,
-
1
);
$type
=
Yii
::
$app
->
request
->
get
(
'type'
,
''
);
$page
=
Yii
::
$app
->
request
->
get
(
'page'
,
1
);
if
(
empty
(
$address
))
{
$msg
=
'请求参数错误'
;
$code
=
-
1
;
$data
=
null
;
goto
doEnd
;
}
$query
=
CoinCTocTransfer
::
find
()
->
where
(
'address= :address'
,
[
':address'
=>
$address
])
->
orderBy
(
'create_time desc'
)
->
groupBy
(
'address, is_sell'
);
if
(
$is_sell
>
-
1
)
{
$query
->
andWhere
(
'is_sell= :is_sell'
,
[
':is_sell'
=>
$is_sell
]);
}
if
(
false
!=
$type
)
{
$query
->
andWhere
(
'type= :type'
,
[
':type'
=>
$type
]);
}
$data
=
$query
->
offset
((
$page
-
1
)
*
20
)
->
limit
(
20
)
->
asArray
()
->
all
();
$countQuery
=
clone
$query
;
$pages
=
new
Pagination
([
'totalCount'
=>
$countQuery
->
count
(),
'pageSize'
=>
20
]);
$data
=
[
'list'
=>
$data
,
'page'
=>
[
'pageCount'
=>
$pages
->
pageCount
,
'pageSize'
=>
20
,
'currentPage'
=>
$page
,
]
];
$code
=
1
;
$msg
=
'success'
;
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
}
public
function
actionOrderStatus
()
{
$address
=
Yii
::
$app
->
request
->
get
(
'address'
,
''
);
$token_name
=
Yii
::
$app
->
request
->
get
(
'token_name'
,
''
);
$market_name
=
Yii
::
$app
->
request
->
get
(
'market_name'
,
''
);
$is_sell
=
Yii
::
$app
->
request
->
get
(
'isSell'
,
-
1
);
$type
=
Yii
::
$app
->
request
->
get
(
'type'
,
''
);
if
(
false
==
$address
||
false
==
$token_name
||
false
==
$market_name
||
false
==
$type
||
-
1
==
$is_sell
)
{
$msg
=
'请求参数错误'
;
$code
=
-
1
;
$data
=
null
;
goto
doEnd
;
}
$latest_model
=
CoinCTocTransfer
::
find
()
->
select
(
'transfer_number'
)
->
where
([
'is_sell'
=>
(
int
)
$is_sell
])
->
andWhere
([
'type'
=>
(
int
)
$type
])
->
andWhere
([
'address'
=>
$address
])
->
andWhere
([
'token_name'
=>
$token_name
])
->
andWhere
([
'market_name'
=>
$market_name
])
->
orderBy
(
'transfer_number desc'
)
->
asArray
()
->
one
();
if
(
false
==
$latest_model
)
{
$msg
=
'订单不存在'
;
$code
=
-
1
;
$step
=
0
;
goto
doEnd
;
}
$orders_info
=
CoinCTocTransfer
::
find
()
->
where
([
'transfer_number'
=>
$latest_model
[
'transfer_number'
]])
->
orderBy
(
'id desc'
)
->
asArray
()
->
all
();
sort
(
$orders_info
);
foreach
(
$orders_info
as
$key
=>
$val
)
{
//未交易
if
(
'0'
==
$val
[
'send_result'
]
&&
'0'
==
$val
[
'query_result'
]
&&
'0'
==
$val
[
'msg'
])
{
$step
=
$key
+
1
;
$code
=
0
;
$msg
=
'第'
.
(
$key
+
1
)
.
'笔交易尚未执行'
;
goto
doEnd
;
}
//交易报错
if
(
'0'
==
$val
[
'send_result'
]
&&
'0'
==
$val
[
'query_result'
]
&&
true
==
$val
[
'msg'
])
{
$step
=
$key
+
1
;
$code
=
-
1
;
$msg
=
$val
[
'msg'
];
goto
doEnd
;
}
//交易成功
if
(
true
==
$val
[
'send_result'
]
&&
'0'
==
$val
[
'query_result'
]
&&
'0'
==
$val
[
'msg'
])
{
$step
=
$key
+
1
;
$code
=
0
;
$msg
=
$val
[
'send_result'
];
goto
doEnd
;
}
//交易成功,查询失败
if
(
true
==
$val
[
'send_result'
]
&&
'success'
!=
$val
[
'query_result'
])
{
$step
=
$key
+
1
;
$code
=
-
1
;
$msg
=
$val
[
'msg'
];
goto
doEnd
;
}
//交易成功,查询成功
if
(
true
==
$val
[
'send_result'
]
&&
'success'
==
$val
[
'query_result'
]
&&
'success'
==
$val
[
'msg'
])
{
if
((
count
(
$orders_info
)
-
1
)
==
$key
)
{
$step
=
((
count
(
$orders_info
)
-
1
)
==
$key
)
?
99
:
(
$key
+
2
);
$code
=
0
;
$msg
=
$val
[
'send_result'
];
goto
doEnd
;
}
continue
;
}
}
doEnd
:
$data
=
[
'step'
=>
$step
,
];
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
}
public
static
function
getrandnums
()
{
$arr
=
array
();
while
(
count
(
$arr
)
<
6
)
{
$arr
[]
=
rand
(
0
,
9
);
$arr
=
array_unique
(
$arr
);
}
return
implode
(
""
,
$arr
);
}
}
\ No newline at end of file
api/controllers/SupportedSymbolController.php
View file @
c63168a3
...
@@ -6,27 +6,90 @@ use api\base\BaseController;
...
@@ -6,27 +6,90 @@ use api\base\BaseController;
use
common\models\psources\CoinAirDropTrade
;
use
common\models\psources\CoinAirDropTrade
;
use
common\models\psources\CoinSupportedSymbol
;
use
common\models\psources\CoinSupportedSymbol
;
use
common\service\chain33\Chain33Service
;
use
common\service\chain33\Chain33Service
;
use
linslin\yii2\curl\Curl
;
use
Yii
;
use
Yii
;
use
yii\helpers\ArrayHelper
;
class
SupportedSymbolController
extends
BaseController
class
SupportedSymbolController
extends
BaseController
{
{
public
function
action
Search
()
public
function
action
Index
()
{
{
$platform_
withhold_id
=
Yii
::
$app
->
request
->
get
(
'
id'
,
''
);
$platform_
id
=
Yii
::
$app
->
request
->
get
(
'platform_
id'
,
''
);
if
(
empty
(
$platform_
withhold_
id
))
{
if
(
empty
(
$platform_id
))
{
$msg
=
'参数不能为空'
;
$msg
=
'参数不能为空'
;
$code
=
-
1
;
$code
=
-
1
;
$data
=
null
;
$data
=
null
;
goto
doEnd
;
goto
doEnd
;
}
}
$coinSupportedSymbol
=
CoinSupportedSymbol
::
find
()
->
select
(
'symbol'
)
->
where
([
'platform_withhold_id'
=>
$platform_withhold_id
])
->
asArray
()
->
all
();
$parentSupportedSymbol
=
CoinSupportedSymbol
::
find
()
->
where
([
'platform_id'
=>
$platform_id
])
->
groupBy
(
'currency'
)
->
all
();
$data
=
array_column
(
$coinSupportedSymbol
,
'symbol'
);
$market
=
[];
foreach
(
$parentSupportedSymbol
as
$val
)
{
$coin_name
[]
=
$val
->
coinInfo
->
name
;
}
$curl
=
new
Curl
();
$data
=
[
"names"
=>
$coin_name
];
$params
=
json_encode
(
$data
);
$curl
->
setHeader
(
'Content-Type'
,
'application/json'
);
$curl
->
setRawPostData
(
$params
);
$res
=
$curl
->
post
(
\Yii
::
$app
->
params
[
'biqianbao'
]
.
'/interface/coin/coin-index'
,
true
);
$res
=
json_decode
(
$res
,
true
);
$res
=
array_column
(
$res
[
'data'
],
NULL
,
'id'
);;
foreach
(
$parentSupportedSymbol
as
&
$val
)
{
$temp
=
[];
$temp
[
'id'
]
=
(
int
)
$val
->
currency
;
$temp
[
'name'
]
=
$val
->
coinInfo
->
name
;
$temp
[
'icon'
]
=
$val
->
coinInfo
->
icon
;
$temp
[
'isToken'
]
=
(
1
==
$val
->
coinInfo
->
treaty
)
?
true
:
false
;
$temp
[
'isParacross'
]
=
(
'BTY'
==
strtoupper
(
$val
->
coinInfo
->
platform
))
?
false
:
true
;
$temp
[
'url'
]
=
'http://www.huifen.com'
;
$temp
[
'platform'
]
=
$val
->
coinInfo
->
platform
;
$temp
[
'rmb'
]
=
isset
(
$res
[
$val
->
currency
][
'rmb'
])
?
$res
[
$val
->
currency
][
'rmb'
]
:
0.00
;
$temp
[
'usd'
]
=
isset
(
$res
[
$val
->
currency
][
'usd'
])
?
$res
[
$val
->
currency
][
'usd'
]
:
0.00
;
array_push
(
$market
,
$temp
);
}
$coin_name
=
[];
foreach
(
$market
as
&
$val
)
{
$childSupportedSymbol
=
CoinSupportedSymbol
::
find
()
->
where
([
'platform_id'
=>
$platform_id
,
'currency'
=>
$val
[
'id'
]])
->
all
();
$tokens
=
[];
foreach
(
$childSupportedSymbol
as
$child
)
{
$coin_name
[]
=
$child
->
baseCurrencyInfo
->
name
;
}
$data_child
=
[
"names"
=>
$coin_name
];
$params
=
json_encode
(
$data_child
);
$curl
=
new
Curl
();
$curl
->
setHeader
(
'Content-Type'
,
'application/json'
);
$curl
->
setRawPostData
(
$params
);
$res
=
$curl
->
post
(
\Yii
::
$app
->
params
[
'biqianbao'
]
.
'/interface/coin/coin-index'
,
true
);
$res
=
json_decode
(
$res
,
true
);
$res
=
array_column
(
$res
[
'data'
],
NULL
,
'id'
);;
foreach
(
$childSupportedSymbol
as
$child
)
{
$temp
=
[];
$temp
[
'id'
]
=
(
int
)
$child
->
base_currency
;
$temp
[
'name'
]
=
$child
->
baseCurrencyInfo
->
name
;
$temp
[
'icon'
]
=
$child
->
baseCurrencyInfo
->
icon
;
$temp
[
'isToken'
]
=
(
1
==
$child
->
baseCurrencyInfo
->
treaty
)
?
true
:
false
;
$temp
[
'isParacross'
]
=
(
'BTY'
==
strtoupper
(
$child
->
baseCurrencyInfo
->
platform
))
?
false
:
true
;
$temp
[
'url'
]
=
'http://www.huifen.com'
;
$temp
[
'platform'
]
=
$child
->
baseCurrencyInfo
->
platform
;
$temp
[
'rmb'
]
=
isset
(
$res
[
$child
->
base_currency
][
'rmb'
])
?
$res
[
$child
->
base_currency
][
'rmb'
]
:
0.00
;
$temp
[
'usd'
]
=
isset
(
$res
[
$child
->
base_currency
][
'usd'
])
?
$res
[
$child
->
base_currency
][
'usd'
]
:
0.00
;
array_push
(
$tokens
,
$temp
);
}
$val
[
'tokens'
]
=
$tokens
;
}
$code
=
0
;
$code
=
0
;
$msg
=
'success'
;
$msg
=
'success'
;
doEnd
:
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$
data
];
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$
market
];
}
}
}
}
\ No newline at end of file
api/controllers/TickerController.php
View file @
c63168a3
...
@@ -357,9 +357,13 @@ class TickerController extends BaseController
...
@@ -357,9 +357,13 @@ class TickerController extends BaseController
$msg
=
'请求参数错误!'
;
$msg
=
'请求参数错误!'
;
goto
doEnd
;
goto
doEnd
;
}
}
$currency
=
CoinSupportedCurrency
::
find
()
->
where
([
'platform_id'
=>
$platform_id
])
->
all
();
$currency
=
CoinSupportedCurrency
::
find
()
->
where
([
'platform_id'
=>
$platform_id
])
->
orderBy
(
'sort'
)
->
all
();
foreach
(
$currency
as
$val
)
{
foreach
(
$currency
as
$val
)
{
if
(
1111
==
$val
->
currency
->
pj_id
)
{
$rate
=
(
string
)
1
;
}
else
{
list
(
$rate
)
=
Yii
::
$app
->
redis_currency
->
hmget
(
'quotation_boc_'
.
'CNY_'
.
$val
->
currency
->
symbol
,
'last'
);
list
(
$rate
)
=
Yii
::
$app
->
redis_currency
->
hmget
(
'quotation_boc_'
.
'CNY_'
.
$val
->
currency
->
symbol
,
'last'
);
}
$val
->
pj_id
=
$val
->
currency
->
pj_id
;
$val
->
pj_id
=
$val
->
currency
->
pj_id
;
$val
->
pj_name
=
$val
->
currency
->
pj_name
;
$val
->
pj_name
=
$val
->
currency
->
pj_name
;
$val
->
pj_symbol
=
$val
->
currency
->
pj_symbol
;
$val
->
pj_symbol
=
$val
->
currency
->
pj_symbol
;
...
...
api/controllers/WalletController.php
View file @
c63168a3
...
@@ -113,8 +113,7 @@ class WalletController extends BaseController
...
@@ -113,8 +113,7 @@ class WalletController extends BaseController
}
}
$coin_model
=
Coin
::
find
()
->
select
(
'name, treaty'
)
->
where
([
'name'
=>
strtoupper
(
$symbol
),
'platform'
=>
$platform
->
platform
])
->
one
();
$coin_model
=
Coin
::
find
()
->
select
(
'name, treaty'
)
->
where
([
'name'
=>
strtoupper
(
$symbol
),
'platform'
=>
$platform
->
platform
])
->
one
();
$service
=
new
Chain33Service
(
$node
);
$address
[]
=
$token
;
$switch
=
false
;
$switch
=
false
;
...
@@ -129,10 +128,18 @@ class WalletController extends BaseController
...
@@ -129,10 +128,18 @@ class WalletController extends BaseController
}
}
}
}
if
(
'BTY'
==
strtoupper
(
$symbol
))
{
$switch
=
true
;
$node
=
\Yii
::
$app
->
params
[
'chain_parallel'
][
'primary'
];
}
$service
=
new
Chain33Service
(
$node
);
$address
[]
=
$token
;
if
(
false
==
$switch
)
{
if
(
false
==
$switch
)
{
$result
=
$service
->
getTokenBalance
(
$address
,
$execer
,
$symbol
);
$result
=
$service
->
getTokenBalance
(
$address
,
$execer
,
$symbol
);
}
else
{
}
else
{
$result
=
$service
->
getBalance
(
$address
,
$execer
);
$result
=
$service
->
getBalance
(
$address
,
$execer
=
''
);
}
}
if
(
0
!==
$result
[
'code'
])
{
if
(
0
!==
$result
[
'code'
])
{
...
...
backend/controllers/CoinSupportedSymbolController.php
View file @
c63168a3
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
namespace
backend\controllers
;
namespace
backend\controllers
;
use
backend\models\coin\CoinSupportedSymbolForm
;
use
backend\models\coin\CoinSupportedSymbolForm
;
use
common\models\psources\Coin
;
use
common\models\psources\CoinSupportedSymbol
;
use
common\models\psources\CoinSupportedSymbol
;
use
Yii
;
use
Yii
;
...
@@ -11,7 +12,7 @@ class CoinSupportedSymbolController extends BaseController
...
@@ -11,7 +12,7 @@ class CoinSupportedSymbolController extends BaseController
{
{
public
function
actionList
()
public
function
actionList
()
{
{
$platform_
withhold_
id
=
Yii
::
$app
->
request
->
get
(
'id'
);
$platform_id
=
Yii
::
$app
->
request
->
get
(
'id'
);
if
(
Yii
::
$app
->
request
->
isAjax
)
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
Yii
::
$app
->
response
->
format
=
'json'
;
$request
=
Yii
::
$app
->
request
;
$request
=
Yii
::
$app
->
request
;
...
@@ -20,47 +21,45 @@ class CoinSupportedSymbolController extends BaseController
...
@@ -20,47 +21,45 @@ class CoinSupportedSymbolController extends BaseController
$id
=
$request
->
get
(
'id'
,
''
);
$id
=
$request
->
get
(
'id'
,
''
);
$where
=
[];
$where
=
[];
if
(
$id
)
{
if
(
$id
)
{
$where
[]
=
[
'platform_
withhold_
id'
=>
$id
];
$where
[]
=
[
'platform_id'
=>
$id
];
}
}
$data
=
CoinSupportedSymbol
::
getList
(
$page
,
$limit
,
$where
);
$data
=
CoinSupportedSymbol
::
getList
(
$page
,
$limit
,
$where
);
$data
[
'code'
]
=
0
;
foreach
(
$data
[
'data'
]
as
&
$val
)
{
$val
->
currency
=
$val
->
coinInfo
->
name
;
$val
->
base_currency
=
$val
->
baseCurrencyInfo
->
name
;
}
Yii
::
$app
->
response
->
format
=
'json'
;
Yii
::
$app
->
response
->
format
=
'json'
;
return
$data
;
return
$data
;
}
}
return
$this
->
render
(
'index'
,
[
'platform_
withhold_id'
=>
$platform_withhold
_id
]);
return
$this
->
render
(
'index'
,
[
'platform_
id'
=>
$platform
_id
]);
}
}
public
function
actionAdd
()
public
function
actionAdd
()
{
{
$this
->
layout
=
false
;
$model
=
new
CoinSupportedSymbolForm
();
$model
=
new
CoinSupportedSymbolForm
();
$model
->
scenario
=
'add'
;
$model
->
scenario
=
'add'
;
if
(
Yii
::
$app
->
request
->
isPost
)
{
if
(
Yii
::
$app
->
request
->
isPost
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
$data
=
Yii
::
$app
->
request
->
post
();
$data
=
Yii
::
$app
->
request
->
post
();
if
(
$model
->
load
(
$data
,
''
)
&&
$model
->
validate
())
{
if
(
$model
->
load
(
$data
,
''
)
&&
$model
->
validate
())
{
$currency
=
Coin
::
find
()
->
select
(
'id'
)
->
where
([
'name'
=>
$data
[
'currency'
]])
->
asArray
()
->
one
();
$base_currency
=
Coin
::
find
()
->
select
(
'id'
)
->
where
([
'name'
=>
$data
[
'base_currency'
]])
->
asArray
()
->
one
();
$coinSupportedSymbol
=
new
CoinSupportedSymbol
();
$coinSupportedSymbol
=
new
CoinSupportedSymbol
();
$coinSupportedSymbol
->
platform_withhold_id
=
$data
[
'platform_withhold_id'
];
$coinSupportedSymbol
->
platform_id
=
$data
[
'platform_id'
];
$coinSupportedSymbol
->
symbol
=
$data
[
'symbol'
];
$coinSupportedSymbol
->
currency
=
$currency
[
'id'
];
$coinSupportedSymbol
->
base_currency
=
$base_currency
[
'id'
];
$result
=
$coinSupportedSymbol
->
save
();
$result
=
$coinSupportedSymbol
->
save
();
if
(
$result
==
=
true
)
{
if
(
$result
!
=
true
)
{
$this
->
success
(
'添加成功'
,
'/admin/coin-supported-symbol/list?id='
.
$data
[
'platform_withhold_id'
])
;
return
[
'code'
=>
-
1
,
'msg'
=>
current
(
$model
->
firstErrors
)]
;
}
}
}
}
//表单验证失败
return
[
'code'
=>
0
,
'msg'
=>
'succeed'
];
$errors
=
$model
->
errors
;
if
(
$errors
)
{
foreach
(
$errors
as
$key
=>
$item
)
{
$errors
=
$item
[
0
];
break
;
}
}
elseif
(
isset
(
$result
)
&&
$result
[
'code'
]
!=
0
)
{
$errors
=
$result
[
'message'
];
}
$this
->
error
(
$errors
,
Yii
::
$app
->
request
->
getReferrer
());
}
}
$platform_
withhold_id
=
Yii
::
$app
->
request
->
get
(
'platform_withhold
_id'
);
$platform_
id
=
Yii
::
$app
->
request
->
get
(
'platform
_id'
);
return
$this
->
render
(
'add'
,
[
'model'
=>
$model
,
'platform_
withhold_id'
=>
$platform_withhold
_id
]);
return
$this
->
render
(
'add'
,
[
'model'
=>
$model
,
'platform_
id'
=>
$platform
_id
]);
}
}
public
function
actionDelete
()
public
function
actionDelete
()
...
...
backend/models/coin/CoinSupportedSymbolForm.php
View file @
c63168a3
...
@@ -2,13 +2,15 @@
...
@@ -2,13 +2,15 @@
namespace
backend\models\coin
;
namespace
backend\models\coin
;
use
common\models\psources\Coin
;
use
yii\base\Model
;
use
yii\base\Model
;
class
CoinSupportedSymbolForm
extends
Model
class
CoinSupportedSymbolForm
extends
Model
{
{
public
$id
;
public
$id
;
public
$platform_withhold_id
;
public
$platform_id
;
public
$symbol
;
public
$currency
;
public
$base_currency
;
public
function
formName
()
public
function
formName
()
{
{
...
@@ -18,34 +20,26 @@ class CoinSupportedSymbolForm extends Model
...
@@ -18,34 +20,26 @@ class CoinSupportedSymbolForm extends Model
public
function
rules
()
public
function
rules
()
{
{
return
[
return
[
[[
'platform_withhold_id'
,
'symbol'
],
'required'
,
'on'
=>
'add'
],
[[
'platform_id'
,
'currency'
,
'base_currency'
],
'required'
,
'on'
=>
'add'
],
[[
'id'
,
'platform_withhold_id'
,
'symbol'
],
'required'
,
'on'
=>
'update'
],
[[
'id'
,
'platform_id'
,
'currency'
,
'base_currency'
],
'required'
,
'on'
=>
'update'
],
[[
'currency'
,
'base_currency'
],
'isExist'
]
];
];
}
}
public
function
attributeLabel
s
()
public
function
scenario
s
()
{
{
return
[
return
[
'id'
=>
'ID'
,
'add'
=>
[
'platform_id'
,
'currency'
,
'base_currency'
],
'platform_withhold_id'
=>
'对应链'
,
'update'
=>
[
'id'
,
'platform_id'
,
'currency'
,
'base_currency'
],
'symbol'
=>
'货币对'
,
];
];
}
}
public
function
scenarios
(
)
public
function
isExist
(
$attribute
,
$params
)
{
{
return
[
$coin_model
=
Coin
::
find
()
->
where
([
'name'
=>
$this
->
currency
])
->
one
();
'add'
=>
[
if
(
false
==
$coin_model
)
{
'platform_withhold_id'
,
$this
->
addError
(
$attribute
,
'币种不存在'
);
'symbol'
return
false
;
],
}
'update'
=>
[
'id'
,
'platform_withhold_id'
,
'symbol'
],
];
}
}
}
}
\ No newline at end of file
backend/views/coin-supported-symbol/add.php
View file @
c63168a3
<h4>
添加货币对
</h4>
<div
style=
"padding: 5px 20px;"
>
<style>
<br>
.layui-form-label
{
<form
id=
"addData"
>
width
:
100px
;
}
</style>
<div
class=
"layui-row"
style=
"padding: 5px;"
>
<div
class=
"layui-col-md6"
>
<form
class=
"layui-form"
method=
"post"
action=
""
>
<input
name=
"_csrf"
type=
"hidden"
value=
"
<?=
Yii
::
$app
->
request
->
getCsrfToken
()
?>
"
>
<input
name=
"_csrf"
type=
"hidden"
value=
"
<?=
Yii
::
$app
->
request
->
getCsrfToken
()
?>
"
>
<div
class=
"layui-inline"
>
<div
class=
"input-group my-group"
>
<label
class=
"layui-form-label"
>
货币对
</label>
<span
class=
"input-group-addon"
>
交易货币
</span>
<div
class=
"layui-input-block"
>
<input
name=
"currency"
type=
"text"
class=
"form-control"
lay-verify=
"required"
>
<input
class=
"layui-input"
name=
"symbol"
lay-verify=
"required"
>
</div>
</div>
<div
class=
"input-group my-group"
>
<span
class=
"input-group-addon"
>
基础货币
</span>
<input
name=
"base_currency"
type=
"text"
class=
"form-control"
lay-verify=
"required"
>
</div>
</div>
<div
class=
"layui-form-item"
>
<input
class=
"layui-input"
name=
"platform_id"
type=
"hidden"
value=
"
<?=
$platform_id
?>
"
<button
class=
"layui-btn"
>
提交
</button>
</div>
<input
class=
"layui-input"
name=
"platform_withhold_id"
type=
"hidden"
value=
"
<?=
$platform_withhold_id
?>
"
lay-verify=
"required"
>
lay-verify=
"required"
>
</form>
</form>
</div>
</div>
</div>
backend/views/coin-supported-symbol/edit.php
deleted
100644 → 0
View file @
956ecc5d
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-5-31
* Time: 下午6:23
*/
?>
<style>
.layui-form-label
{
width
:
100px
;
}
</style>
<div
class=
"layui-row"
style=
"padding: 5px;"
>
<div
class=
"layui-col-md12"
>
<form
class=
"layui-form"
method=
"post"
action=
""
id=
"walletEdit"
>
<input
name=
"_csrf"
type=
"hidden"
value=
"
<?=
Yii
::
$app
->
request
->
getCsrfToken
()
?>
"
>
<input
name=
"id"
type=
"hidden"
value=
"
<?=
$model
->
id
?>
"
>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
简称
</label>
<div
class=
"layui-input-block"
>
<input
class=
"layui-input"
name=
"name"
value=
"
<?=
$model
->
name
?>
"
lay-verify=
"required"
>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
下载地址
</label>
<div
class=
"layui-input-block"
>
<input
class=
"layui-input"
name=
"download_url"
value=
"
<?=
$model
->
download_url
?>
"
>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
介绍
</label>
<div
class=
"layui-input-block"
>
<textarea
class=
"layui-textarea"
name=
"introduce"
>
<?=
$model
->
introduce
?>
</textarea>
</div>
</div>
</form>
</div>
</div>
<script>
var
laydate
=
layui
.
laydate
;
laydate
.
render
({
elem
:
"#time1"
});
//图片上传
var
uploader
=
layui
.
upload
;
$_csrf
=
$
(
"input[name='_csrf']"
).
val
();
uploader
.
render
({
elem
:
"#upload1"
,
url
:
'/admin/coin/upload'
,
data
:
{
_csrf
:
$_csrf
},
done
:
function
(
res
)
{
console
.
log
(
res
.
data
.
src
);
$
(
"input[name='icon']"
).
val
(
res
.
data
.
src
);
$
(
"#icon1"
).
attr
(
'src'
,
res
.
data
.
src
);
},
error
:
function
(
res
)
{
}
});
//form render
var
form
=
layui
.
form
;
form
.
render
();
</script>
backend/views/coin-supported-symbol/index.php
View file @
c63168a3
...
@@ -16,15 +16,13 @@ IndexAsset::register($this);
...
@@ -16,15 +16,13 @@ IndexAsset::register($this);
padding
:
0px
;
padding
:
0px
;
}
}
</style>
</style>
<h4>
货币
对
列表
</h4>
<h4>
货币列表
</h4>
<div
class=
"layui-row"
>
<div
class=
"layui-row"
>
<div
class=
"layui-col-md1"
>
<div
class=
"layui-col-md1"
>
<a
href=
"/admin/coin-supported-symbol/add?platform_withhold_id=
<?=
$platform_withhold_id
?>
"
"
>
<button
class=
"layui-btn layui-btn-sm"
lay-event=
"add"
id=
"add"
>
单笔添加
</button>
<button
class=
"layui-btn layui-btn-default"
id=
"add"
>
添加货币对
</button>
</a>
</div>
</div>
</div>
</div>
<input
id=
"platform_
withhold_id"
type=
"hidden"
value=
"
<?=
$platform_withhold
_id
?>
"
>
<input
id=
"platform_
id"
type=
"hidden"
value=
"
<?=
$platform
_id
?>
"
>
<div
class=
"layui-row"
>
<div
class=
"layui-row"
>
<table
class=
"layui-table"
id=
"table1"
lay-filter=
"table1"
></table>
<table
class=
"layui-table"
id=
"table1"
lay-filter=
"table1"
></table>
</div>
</div>
...
...
backend/views/wallet/index.php
View file @
c63168a3
...
@@ -44,5 +44,6 @@ IndexAsset::register($this);
...
@@ -44,5 +44,6 @@ IndexAsset::register($this);
<script
type=
"text/html"
id=
"operationTpl"
>
<script
type=
"text/html"
id=
"operationTpl"
>
<
a
class
=
"layui-btn layui-btn-xs"
lay
-
event
=
"edit"
>
编辑
<
/a
>
<
a
class
=
"layui-btn layui-btn-xs"
lay
-
event
=
"edit"
>
编辑
<
/a
>
<
a
class
=
"layui-btn layui-btn-xs"
lay
-
event
=
"delete"
>
删除
<
/a
>
<
a
class
=
"layui-btn layui-btn-xs"
lay
-
event
=
"delete"
>
删除
<
/a
>
<
a
class
=
"layui-btn layui-btn-primary layui-btn-xs"
href
=
"/admin/coin-supported-coin/list?id={{d.id}}"
>
支持发行货币种类
<
/a
>
<
a
class
=
"layui-btn layui-btn-primary layui-btn-xs"
href
=
"/admin/coin-supported-symbol/list?id={{d.id}}"
>
C2C
支持货币对
<
/a
>
<
a
class
=
"layui-btn layui-btn-primary layui-btn-xs"
href
=
"/admin/coin-supported-coin/list?id={{d.id}}"
>
支持发行货币种类
<
/a
>
</script>
</script>
backend/web/js/coin-supported-symbol/index.js
View file @
c63168a3
...
@@ -5,16 +5,33 @@ var table = layui.table;
...
@@ -5,16 +5,33 @@ var table = layui.table;
var
form
=
layui
.
form
;
var
form
=
layui
.
form
;
var
layer
=
layui
.
layer
;
var
layer
=
layui
.
layer
;
form
.
render
();
form
.
render
();
var
platform_
withhold_id
=
$
(
"#platform_withhold
_id"
).
val
();
var
platform_
id
=
$
(
"#platform
_id"
).
val
();
var
tableIns
=
table
.
render
({
var
tableIns
=
table
.
render
({
elem
:
"#table1"
,
elem
:
"#table1"
,
url
:
'/admin/coin-supported-symbol/list?id='
+
platform_
withhold_
id
,
url
:
'/admin/coin-supported-symbol/list?id='
+
platform_id
,
limit
:
10
,
limit
:
10
,
page
:
1
,
page
:
1
,
loading
:
true
,
loading
:
true
,
cols
:
[[
cols
:
[[
{
field
:
'id'
,
title
:
'ID'
},
{
field
:
'id'
,
title
:
'ID'
},
{
field
:
'symbol'
,
title
:
'货币对'
},
{
field
:
'currency'
,
title
:
'交易货币'
,
//templet: function (data) {
//var name = JSON.parse(data.name);
//console.log(typeof (data.name), name.zh);
//return name.zh
//}
},
{
field
:
'base_currency'
,
title
:
'基础货币'
,
//templet: function (data) {
//var name = JSON.parse(data.name);
//console.log(typeof (data.name), name.zh);
//return name.zh
//}
},
{
field
:
'create_time'
,
title
:
'创建时间'
},
{
field
:
'create_time'
,
title
:
'创建时间'
},
{
field
:
'id'
,
title
:
'操作'
,
templet
:
'#operationTpl'
}
{
field
:
'id'
,
title
:
'操作'
,
templet
:
'#operationTpl'
}
]],
]],
...
@@ -30,7 +47,7 @@ form.on('submit(form1)', function (data) {
...
@@ -30,7 +47,7 @@ form.on('submit(form1)', function (data) {
table
.
on
(
'tool(table1)'
,
function
(
obj
)
{
table
.
on
(
'tool(table1)'
,
function
(
obj
)
{
var
data
=
obj
.
data
;
var
data
=
obj
.
data
;
if
(
obj
.
event
==
'delete'
)
{
if
(
obj
.
event
==
'delete'
)
{
layer
.
confirm
(
'真的要删除'
+
data
.
symbol
+
'吗?'
,
{
icon
:
3
,
title
:
'删除'
},
function
(
index
)
{
layer
.
confirm
(
'真的要删除'
+
data
.
coin_name
+
'吗?'
,
{
icon
:
3
,
title
:
'删除'
},
function
(
index
)
{
layer
.
close
(
index
);
layer
.
close
(
index
);
//向服务端发送删除指令
//向服务端发送删除指令
$
.
get
(
'/admin/coin-supported-symbol/delete?id='
+
obj
.
data
.
id
,
function
(
data
,
status
)
{
$
.
get
(
'/admin/coin-supported-symbol/delete?id='
+
obj
.
data
.
id
,
function
(
data
,
status
)
{
...
@@ -42,3 +59,31 @@ table.on('tool(table1)', function (obj) {
...
@@ -42,3 +59,31 @@ table.on('tool(table1)', function (obj) {
});
});
}
}
});
});
$
(
'#add'
).
click
(
function
()
{
//打开弹窗
$
.
get
(
'/admin/coin-supported-symbol/add?platform_id='
+
platform_id
,
{},
function
(
str
)
{
var
index
=
layer
.
open
({
type
:
1
,
title
:
'添加数据'
,
id
:
'add-one'
,
skin
:
'layui-layer-lan'
,
area
:
[
'320px'
,
'auto'
],
content
:
str
,
btn
:
[
'确认'
,
'取消'
],
btn1
:
function
()
{
$
.
post
(
'/admin/coin-supported-symbol/add'
,
$
(
"#addData"
).
serialize
(),
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
//if (rev.code == 0) {
layer
.
close
(
index
);
table
.
reload
(
"table1"
,
{});
//}
});
}
});
layui
.
form
.
render
();
});
return
false
;
});
\ No newline at end of file
common/business/ExchangeBusiness.php
View file @
c63168a3
...
@@ -45,9 +45,16 @@ class ExchangeBusiness
...
@@ -45,9 +45,16 @@ class ExchangeBusiness
16
=>
'Bitnasdaq'
,
16
=>
'Bitnasdaq'
,
17
=>
'Dag'
,
17
=>
'Dag'
,
18
=>
'Boc'
,
18
=>
'Boc'
,
//1 => 'Hadax', //不需要
//2 => 'Bitfinex', //不需要
//3 => 'Bittrex', //不需要
//4 => 'Zb', //不需要
//5 => 'Zg',//不需要
//6 => 'Biki',//不需要
//7 => 'S',//已挂
//7 => 'S',//已挂
//
11
=> 'Gdpro',//已挂
//
7
=> 'Gdpro',//已挂
//
16
=> 'Ceohk', //已挂
//
8
=> 'Ceohk', //已挂
];
];
/**
/**
...
@@ -61,7 +68,7 @@ class ExchangeBusiness
...
@@ -61,7 +68,7 @@ class ExchangeBusiness
{
{
$coin_quotation_disable_items
=
Yii
::
$app
->
params
[
'coin_quotation_disable_items'
];
$coin_quotation_disable_items
=
Yii
::
$app
->
params
[
'coin_quotation_disable_items'
];
if
(
strtoupper
(
$tag
)
==
'CCNY'
||
strtoupper
(
$tag
)
==
'CNYT'
)
{
if
(
strtoupper
(
$tag
)
==
'CCNY'
||
strtoupper
(
$tag
)
==
'CNYT'
)
{
$exchange
=
ExchangeFactory
::
createExchange
(
"
Bty
"
);
$exchange
=
ExchangeFactory
::
createExchange
(
"
Zhaobi
"
);
$rate
=
$exchange
->
getTicker
(
"BTY"
,
"USDT"
);
$rate
=
$exchange
->
getTicker
(
"BTY"
,
"USDT"
);
$rate
=
(
float
)
$rate
[
'rmb'
]
/
$rate
[
'last'
];
$rate
=
(
float
)
$rate
[
'rmb'
]
/
$rate
[
'last'
];
$quotation
[
'rmb'
]
=
1.00
;
$quotation
[
'rmb'
]
=
1.00
;
...
@@ -115,46 +122,52 @@ class ExchangeBusiness
...
@@ -115,46 +122,52 @@ class ExchangeBusiness
}
}
$f
=
false
;
$f
=
false
;
$quotation
=
[];
$quotation
=
[];
if
(
in_array
(
strtoupper
(
$tag
),
[
'DRA'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Draex"
);
$quotation
=
$exchange
->
getTicker
(
$tag
,
'USDT'
);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'last'
]);
goto
doEnd
;
}
if
(
in_array
(
strtoupper
(
$tag
),
[
'FOLI'
]))
{
if
(
in_array
(
strtoupper
(
$tag
),
[
'FOLI'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Ex"
);
$exchange
=
ExchangeFactory
::
createExchange
(
"Ex"
);
$quotation
=
$exchange
->
getTicker
(
$tag
,
'USDT'
);
$quotation
=
$exchange
->
getTicker
(
$tag
,
'USDT'
);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.
2
f"
,
$quotation
[
'last'
]);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.
4
f"
,
$quotation
[
'last'
]);
goto
doEnd
;
goto
doEnd
;
}
}
if
(
in_array
(
strtoupper
(
$tag
),
[
'DAG'
]))
{
if
(
in_array
(
strtoupper
(
$tag
),
[
'DAG'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Dag"
);
$exchange
=
ExchangeFactory
::
createExchange
(
"Dag"
);
$quotation
=
$exchange
->
getTicker
(
$tag
,
'USDT'
);
$quotation
=
$exchange
->
getTicker
(
$tag
,
'USDT'
);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.
2
f"
,
$quotation
[
'last'
]);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.
4
f"
,
$quotation
[
'last'
]);
goto
doEnd
;
goto
doEnd
;
}
}
if
(
in_array
(
strtoupper
(
$tag
),
[
'BNC'
]))
{
if
(
in_array
(
strtoupper
(
$tag
),
[
'BNC'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Bitnasdaq"
);
$exchange
=
ExchangeFactory
::
createExchange
(
"Bitnasdaq"
);
$quotation
=
$exchange
->
getTicker
(
$tag
,
'USDT'
);
$quotation
=
$exchange
->
getTicker
(
$tag
,
'USDT'
);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.
2
f"
,
$quotation
[
'last'
]);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.
4
f"
,
$quotation
[
'last'
]);
goto
doEnd
;
goto
doEnd
;
}
}
if
(
in_array
(
strtoupper
(
$tag
),
[
'GM'
,
'BSTC'
]))
{
if
(
in_array
(
strtoupper
(
$tag
),
[
'GM'
,
'BSTC'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Token7"
);
$exchange
=
ExchangeFactory
::
createExchange
(
"Token7"
);
$quotation
=
$exchange
->
getTicker
(
$tag
,
'HA'
);
$quotation
=
$exchange
->
getTicker
(
$tag
,
'HA'
);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.
2
f"
,
$quotation
[
'last'
]);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.
4
f"
,
$quotation
[
'last'
]);
goto
doEnd
;
goto
doEnd
;
}
}
if
(
in_array
(
strtoupper
(
$tag
),
[
'BECC'
]))
{
if
(
in_array
(
strtoupper
(
$tag
),
[
'BECC'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"S"
);
$exchange
=
ExchangeFactory
::
createExchange
(
"S"
);
$quotation
=
$exchange
->
getTicker
(
$tag
,
'ST'
);
$quotation
=
$exchange
->
getTicker
(
$tag
,
'ST'
);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.
2
f"
,
$quotation
[
'last'
]);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.
4
f"
,
$quotation
[
'last'
]);
goto
doEnd
;
goto
doEnd
;
}
}
if
(
in_array
(
strtoupper
(
$tag
),
[
'GHP'
]))
{
if
(
in_array
(
strtoupper
(
$tag
),
[
'GHP'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"
Zg
"
);
$exchange
=
ExchangeFactory
::
createExchange
(
"
Bitnasdaq
"
);
$quotation
=
$exchange
->
getTicker
(
$tag
,
'CNZ'
);
$quotation
=
$exchange
->
getTicker
(
$tag
);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.
2
f"
,
$quotation
[
'last'
]);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.
4
f"
,
$quotation
[
'last'
]);
goto
doEnd
;
goto
doEnd
;
}
}
...
@@ -164,28 +177,28 @@ class ExchangeBusiness
...
@@ -164,28 +177,28 @@ class ExchangeBusiness
$quotation
[
'low'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'low'
]);
$quotation
[
'low'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'low'
]);
$quotation
[
'high'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'high'
]);
$quotation
[
'high'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'high'
]);
$quotation
[
'last'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'last'
]);
$quotation
[
'last'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'last'
]);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.
2
f"
,
$quotation
[
'last'
]);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.
4
f"
,
$quotation
[
'last'
]);
goto
doEnd
;
goto
doEnd
;
}
}
if
(
in_array
(
strtoupper
(
$tag
),
[
'CTG'
]))
{
if
(
in_array
(
strtoupper
(
$tag
),
[
'CTG'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Gdpro"
);
$exchange
=
ExchangeFactory
::
createExchange
(
"Gdpro"
);
$quotation
=
$exchange
->
getTicker
(
$tag
,
'CNY'
);
$quotation
=
$exchange
->
getTicker
(
$tag
,
'CNY'
);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.
2
f"
,
$quotation
[
'last'
]);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.
4
f"
,
$quotation
[
'last'
]);
goto
doEnd
;
goto
doEnd
;
}
}
if
(
in_array
(
strtoupper
(
$tag
),
[
'USDT'
]))
{
if
(
in_array
(
strtoupper
(
$tag
),
[
'USDT'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Go"
);
$exchange
=
ExchangeFactory
::
createExchange
(
"Go"
);
$quotation
=
$exchange
->
getTicker
(
'CNY'
,
'USD'
);
$quotation
=
$exchange
->
getTicker
(
'CNY'
,
'USD'
);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.
2
f"
,
$quotation
[
'last'
]);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.
4
f"
,
$quotation
[
'last'
]);
goto
doEnd
;
goto
doEnd
;
}
}
if
(
in_array
(
strtoupper
(
$tag
),
[
'SUSD'
]))
{
if
(
in_array
(
strtoupper
(
$tag
),
[
'SUSD'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Go"
);
$exchange
=
ExchangeFactory
::
createExchange
(
"Go"
);
$quotation
=
$exchange
->
getTicker
(
'CNY'
,
'USD'
);
$quotation
=
$exchange
->
getTicker
(
'CNY'
,
'USD'
);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.
2
f"
,
$quotation
[
'last'
]);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.
4
f"
,
$quotation
[
'last'
]);
goto
doEnd
;
goto
doEnd
;
}
}
...
@@ -198,7 +211,7 @@ class ExchangeBusiness
...
@@ -198,7 +211,7 @@ class ExchangeBusiness
if
(
in_array
(
strtoupper
(
$tag
),
[
'TSC'
]))
{
if
(
in_array
(
strtoupper
(
$tag
),
[
'TSC'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Tsc"
);
$exchange
=
ExchangeFactory
::
createExchange
(
"Tsc"
);
$quotation
=
$exchange
->
getTicker
(
'TSC'
,
'CNDT'
);
$quotation
=
$exchange
->
getTicker
(
'TSC'
,
'CNDT'
);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.
2
f"
,
$quotation
[
'last'
]);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.
4
f"
,
$quotation
[
'last'
]);
goto
doEnd
;
goto
doEnd
;
}
}
...
@@ -296,7 +309,7 @@ class ExchangeBusiness
...
@@ -296,7 +309,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'
]))
{
if
(
in_array
(
strtoupper
(
$tag
),
[
'FOLI'
,
'CIC'
,
'KPC8'
,
'BVA'
,
'DAG'
,
'BNC'
,
'GHP'
,
'DRA'
]))
{
$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
);
}
else
if
(
in_array
(
strtoupper
(
$tag
),
[
'SUSD'
]))
{
}
else
if
(
in_array
(
strtoupper
(
$tag
),
[
'SUSD'
]))
{
...
...
common/models/psources/CoinCTocTransfer.php
0 → 100644
View file @
c63168a3
<?php
namespace
common\models\psources
;
use
Yii
;
use
common\core\BaseActiveRecord
;
class
CoinCTocTransfer
extends
BaseActiveRecord
{
const
TYPE_SELL
=
1
;
//卖单
const
TYPE_BUY
=
0
;
//买单
const
CONSENSUE_YES
=
1
;
//需要
const
CONSENSUE_NO
=
0
;
//不需要
const
TYPE_ORDER
=
1
;
//挂单
const
TYPE_TRANSFER
=
2
;
//交易
const
TYPE_REVOKE
=
3
;
//撤消
const
C2C_ORDERING
=
'C2C_ORDERING'
;
const
C2C_ORDER_FAILED
=
'C2C_ORDER_FAILED'
;
public
static
function
getDb
()
{
return
Yii
::
$app
->
get
(
'p_sources'
);
}
public
static
function
tableName
()
{
return
'{{%coin_ctoc_transfer}}'
;
}
//定义场景
const
SCENARIOS_CREATE
=
'create'
;
public
function
rules
()
{
return
[
[[
'is_sell'
,
'type'
,
'address'
,
'token_name'
,
'market_name'
,
'price'
,
'amount'
,
'step'
,
'txhex'
,
'transfer_url'
,
'transfer_number'
,
'consensus'
],
'required'
],
[[
'send_result'
,
'query_result'
,
'msg'
],
'safe'
]
];
}
public
function
scenarios
()
{
$scenarios
=
[
self
::
SCENARIOS_CREATE
=>
[
'is_sell'
,
'type'
,
'address'
,
'token_name'
,
'market_name'
,
'price'
,
'amount'
,
'step'
,
'txhex'
,
'transfer_url'
,
'transfer_number'
,
'consensus'
],
];
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
}
}
common/models/psources/CoinIssueCoin.php
View file @
c63168a3
...
@@ -48,7 +48,7 @@ class CoinIssueCoin extends CommonActiveRecord
...
@@ -48,7 +48,7 @@ class CoinIssueCoin extends CommonActiveRecord
return
[
return
[
[[
'name'
,
'symbol'
,
'total'
,
'owner'
,
'introduction'
,
'category'
,
'type'
,
'platform_id'
,
'chain_id'
,
'charge_unit'
,
'charge'
],
'required'
],
[[
'name'
,
'symbol'
,
'total'
,
'owner'
,
'introduction'
,
'category'
,
'type'
,
'platform_id'
,
'chain_id'
,
'charge_unit'
,
'charge'
],
'required'
],
[[
'total'
,
'category'
,
'type'
,
'platform_id'
,
'chain_id'
],
'integer'
],
[[
'total'
,
'category'
,
'type'
,
'platform_id'
,
'chain_id'
],
'integer'
],
[[
'introduction'
,
'charge_unit'
],
'string'
,
'length'
=>
[
1
,
20
]],
[[
'introduction'
,
'charge_unit'
],
'string'
,
'length'
=>
[
1
,
20
]],
[
'symbol'
,
'string'
,
'length'
=>
[
1
,
6
]],
[
'symbol'
,
'string'
,
'length'
=>
[
1
,
6
]],
[
'name'
,
'string'
,
'length'
=>
[
1
,
20
]],
[
'name'
,
'string'
,
'length'
=>
[
1
,
20
]],
#['status', 'in', 'range' => [1, 2, 0]],
#['status', 'in', 'range' => [1, 2, 0]],
...
@@ -85,7 +85,10 @@ class CoinIssueCoin extends CommonActiveRecord
...
@@ -85,7 +85,10 @@ class CoinIssueCoin extends CommonActiveRecord
//非增发
//非增发
if
(
CoinIssueCoin
::
TYPE_NO
==
$this
->
type
)
{
if
(
CoinIssueCoin
::
TYPE_NO
==
$this
->
type
)
{
$model
=
CoinIssueCoin
::
find
()
->
where
([
'name'
=>
$this
->
name
,
'platform_id'
=>
$this
->
platform_id
,
'status'
=>
CoinIssueCoin
::
STATUS_SUCCESS
])
->
orderBy
(
'id desc'
)
->
one
();
$model
=
CoinIssueCoin
::
find
()
->
where
([
'name'
=>
$this
->
name
,
'platform_id'
=>
$this
->
platform_id
])
->
andWhere
([
'<>'
,
'status'
,
CoinIssueCoin
::
STATUS_FAILED
])
->
orderBy
(
'id desc'
)
->
one
();
if
(
$model
)
{
if
(
$model
)
{
$this
->
addError
(
$attribute
,
'Token名称已存在'
);
$this
->
addError
(
$attribute
,
'Token名称已存在'
);
return
false
;
return
false
;
...
@@ -112,7 +115,10 @@ class CoinIssueCoin extends CommonActiveRecord
...
@@ -112,7 +115,10 @@ class CoinIssueCoin extends CommonActiveRecord
}
}
}
}
if
(
CoinIssueCoin
::
TYPE_NO
==
$this
->
type
)
{
if
(
CoinIssueCoin
::
TYPE_NO
==
$this
->
type
)
{
$model
=
CoinIssueCoin
::
find
()
->
where
([
'symbol'
=>
$this
->
symbol
,
'platform_id'
=>
$this
->
platform_id
,
'status'
=>
CoinIssueCoin
::
STATUS_SUCCESS
])
->
orderBy
(
'id desc'
)
->
one
();
$model
=
CoinIssueCoin
::
find
()
->
where
([
'symbol'
=>
$this
->
symbol
,
'platform_id'
=>
$this
->
platform_id
])
->
andWhere
([
'<>'
,
'status'
,
CoinIssueCoin
::
STATUS_FAILED
])
->
orderBy
(
'id desc'
)
->
one
();
if
(
$model
)
{
if
(
$model
)
{
$this
->
addError
(
$attribute
,
'Token名称已存在'
);
$this
->
addError
(
$attribute
,
'Token名称已存在'
);
return
false
;
return
false
;
...
...
common/models/psources/CoinSupportedSymbol.php
View file @
c63168a3
...
@@ -16,9 +16,9 @@ class CoinSupportedSymbol extends BaseActiveRecord
...
@@ -16,9 +16,9 @@ class CoinSupportedSymbol extends BaseActiveRecord
$query
=
$query
->
andWhere
(
$item
);
$query
=
$query
->
andWhere
(
$item
);
}
}
$count
=
$query
->
count
();
$count
=
$query
->
count
();
$data
=
$query
->
offset
((
$page
-
1
)
*
10
)
->
limit
(
$limit
)
->
a
sArray
()
->
a
ll
();
$data
=
$query
->
offset
((
$page
-
1
)
*
10
)
->
limit
(
$limit
)
->
all
();
return
[
'count'
=>
$count
,
'data'
=>
$data
];
return
[
'count'
=>
$count
,
'data'
=>
$data
,
'code'
=>
0
];
}
}
public
function
addOne
(
$params
)
public
function
addOne
(
$params
)
...
@@ -36,4 +36,20 @@ class CoinSupportedSymbol extends BaseActiveRecord
...
@@ -36,4 +36,20 @@ class CoinSupportedSymbol extends BaseActiveRecord
return
[
'code'
=>
$exception
->
getCode
(),
'message'
=>
$exception
->
getMessage
()];
return
[
'code'
=>
$exception
->
getCode
(),
'message'
=>
$exception
->
getMessage
()];
}
}
}
}
// public function attributes()
// {
// return array_merge(parent::attributes(), ['code']);
// }
public
function
getCoinInfo
()
{
return
$this
->
hasOne
(
Coin
::
class
,
[
'id'
=>
'currency'
]);
}
public
function
getBaseCurrencyInfo
()
{
return
$this
->
hasOne
(
Coin
::
class
,
[
'id'
=>
'base_currency'
]);
}
}
}
common/models/pwallet/Notice.php
View file @
c63168a3
...
@@ -13,11 +13,82 @@ use common\core\BaseActiveRecord;
...
@@ -13,11 +13,82 @@ use common\core\BaseActiveRecord;
class
Notice
extends
BaseActiveRecord
class
Notice
extends
BaseActiveRecord
{
{
const
STATUS_ON
=
1
;
//激活
const
STATUS_OFF
=
0
;
//未激活
const
TYPE_ROLL
=
1
;
//滚动
const
TYPE_POP
=
0
;
//弹窗
//定义场景
const
SCENARIOS_CREATE
=
'create'
;
const
SCENARIOS_UPDATE
=
'update'
;
public
static
function
getDb
()
public
static
function
getDb
()
{
{
return
Yii
::
$app
->
get
(
'db_pwallet'
);
return
Yii
::
$app
->
get
(
'db_pwallet'
);
}
}
public
function
rules
()
{
return
[
[[
'title'
,
'content'
,
'type'
,
'status'
,
'platform_id'
,
'author'
],
'required'
],
[[
'status'
,
'type'
,
'platform_id'
,
'is_top'
],
'integer'
],
[
'is_top'
,
'verfiyIsTop'
],
[
'type'
,
'verfiyType'
],
[[
'is_top'
],
'safe'
]
];
}
public
function
verfiyIsTop
(
$attribute
,
$params
)
{
$count
=
self
::
find
()
->
where
([
'platform_id'
=>
$this
->
platform_id
,
'is_top'
=>
$this
->
is_top
])
->
count
();
if
(
$count
>=
1
)
{
$this
->
addError
(
$attribute
,
'置顶公告只能1条'
);
return
false
;
}
}
public
function
verfiyType
(
$attribute
,
$params
)
{
if
(
'create'
==
self
::
getScenario
())
{
$count
=
self
::
find
()
->
where
([
'platform_id'
=>
$this
->
platform_id
,
'type'
=>
$this
->
type
])
->
count
();
if
(
Notice
::
TYPE_ROLL
==
$this
->
type
)
{
if
(
$count
>=
3
)
{
$this
->
addError
(
$attribute
,
'滚动公告最多只能3条'
);
return
false
;
}
}
if
(
Notice
::
TYPE_POP
==
$this
->
type
)
{
if
(
$count
>=
1
)
{
$this
->
addError
(
$attribute
,
'弹窗公告最多只能3条'
);
return
false
;
}
}
}
}
public
function
scenarios
()
{
$scenarios
=
[
self
::
SCENARIOS_CREATE
=>
[
'title'
,
'content'
,
'author'
,
'status'
,
'type'
,
'platform_id'
,
'is_top'
],
self
::
SCENARIOS_UPDATE
=>
[
'id'
,
'title'
,
'content'
,
'author'
,
'status'
,
'type'
,
'platform_id'
,
'is_top'
],
];
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
}
public
function
attributeLabels
()
{
return
[
'title'
=>
'公告标题'
,
'content'
=>
'公告内容'
,
'author'
=>
'作者'
,
'status'
=>
'公告状态'
,
'type'
=>
'公告类型'
,
'platform_id'
=>
'钱包'
,
];
}
public
static
function
getList
(
$page
=
1
,
$limit
=
10
,
$condition
=
[])
public
static
function
getList
(
$page
=
1
,
$limit
=
10
,
$condition
=
[])
{
{
$query
=
self
::
find
();
$query
=
self
::
find
();
...
...
common/service/chain33/Chain33Service.php
View file @
c63168a3
...
@@ -256,7 +256,7 @@ class Chain33Service
...
@@ -256,7 +256,7 @@ class Chain33Service
return
$this
->
send
(
$params
,
'Chain33.Query'
);
return
$this
->
send
(
$params
,
'Chain33.Query'
);
}
}
public
function
getBalance
(
$address
,
$execer
)
public
function
getBalance
(
$address
,
$execer
=
""
)
{
{
$params
=
[
$params
=
[
'addresses'
=>
$address
,
'addresses'
=>
$address
,
...
...
common/service/exchange/Boc.php
View file @
c63168a3
...
@@ -15,7 +15,7 @@ class Boc extends Exchange implements ExchangeInterface
...
@@ -15,7 +15,7 @@ class Boc extends Exchange implements ExchangeInterface
{
{
protected
$supported_symbol
=
'supported_symbol_boc'
;
protected
$supported_symbol
=
'supported_symbol_boc'
;
protected
$quotation_prefix
=
'quotation_boc_'
;
protected
$quotation_prefix
=
'quotation_boc_'
;
protected
$base_url
=
'http://srh.bankofchina.com/search/whpj/search
.jsp'
;
protected
$base_url
=
'https://srh.bankofchina.com/search/whpj/search_cn
.jsp'
;
public
function
symbolExists
(
$tag
=
'CNY'
,
$aim
=
"JPY"
)
public
function
symbolExists
(
$tag
=
'CNY'
,
$aim
=
"JPY"
)
{
{
...
@@ -25,6 +25,7 @@ class Boc extends Exchange implements ExchangeInterface
...
@@ -25,6 +25,7 @@ class Boc extends Exchange implements ExchangeInterface
}
}
return
false
;
return
false
;
}
}
/**
/**
* 转化交易对为请求变量
* 转化交易对为请求变量
*
*
...
@@ -34,7 +35,7 @@ class Boc extends Exchange implements ExchangeInterface
...
@@ -34,7 +35,7 @@ class Boc extends Exchange implements ExchangeInterface
*/
*/
public
function
formatSymbol
(
$tag
=
'CNY'
,
$aim
=
'JPY'
)
public
function
formatSymbol
(
$tag
=
'CNY'
,
$aim
=
'JPY'
)
{
{
return
strtoupper
(
$tag
.
'_'
.
$aim
);
return
strtoupper
(
$tag
.
'_'
.
$aim
);
}
}
/**
/**
...
@@ -60,13 +61,14 @@ class Boc extends Exchange implements ExchangeInterface
...
@@ -60,13 +61,14 @@ class Boc extends Exchange implements ExchangeInterface
'erectDate'
=>
''
,
'erectDate'
=>
''
,
'nothing'
=>
''
,
'nothing'
=>
''
,
'pjname'
=>
1323
'pjname'
=>
1323
])
->
post
(
'http
://srh.bankofchina.com/search/whpj/search
.jsp'
);
])
->
post
(
'http
s://srh.bankofchina.com/search/whpj/search_cn
.jsp'
);
$response
=
iconv
(
'UTF-8'
,
'GBK//TRANSLIT'
,
$response
);
$response
=
iconv
(
'UTF-8'
,
'GBK//TRANSLIT'
,
$response
);
$html
=
HtmlDomParser
::
str_get_html
(
$response
);
$html
=
HtmlDomParser
::
str_get_html
(
$response
);
$div
=
(
$html
->
find
(
'div.BOC_main'
));
$div
=
(
$html
->
find
(
'div.BOC_main'
));
foreach
(
$div
->
find
(
'td'
)
as
$key
=>
$e
){
if
(
$div
->
find
(
'td'
))
{
if
(
$key
==
5
){
foreach
(
$div
->
find
(
'td'
)
as
$key
=>
$e
)
{
if
(
$key
==
5
)
{
$key
=
$this
->
quotation_prefix
.
'CNY_JPY'
;
$key
=
$this
->
quotation_prefix
.
'CNY_JPY'
;
$this
->
redis
->
hmset
(
$key
,
'low'
,
$e
->
innertext
,
'high'
,
$e
->
innertext
,
'last'
,
$e
->
innertext
);
$this
->
redis
->
hmset
(
$key
,
'low'
,
$e
->
innertext
,
'high'
,
$e
->
innertext
,
'last'
,
$e
->
innertext
);
$this
->
redis
->
sadd
(
$this
->
supported_symbol
,
'CNYJPY'
);
$this
->
redis
->
sadd
(
$this
->
supported_symbol
,
'CNYJPY'
);
...
@@ -74,5 +76,6 @@ class Boc extends Exchange implements ExchangeInterface
...
@@ -74,5 +76,6 @@ class Boc extends Exchange implements ExchangeInterface
}
}
}
}
}
}
}
}
}
\ No newline at end of file
common/service/exchange/Draex.php
0 → 100644
View file @
c63168a3
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-6-26
* Time: 下午7:21
*/
namespace
common\service\exchange
;
use
Yii
;
use
linslin\yii2\curl\Curl
;
class
Draex
extends
Exchange
implements
ExchangeInterface
{
protected
$supported_symbol
=
'supported_symbol_draex'
;
protected
$quotation_prefix
=
'quotation_draex_'
;
protected
$base_url
=
'https://www.draex.co'
;
public
function
formatSymbol
(
$tag
=
'DRA'
,
$aim
=
'USDT'
)
{
return
strtolower
(
trim
(
$tag
)
.
trim
(
$aim
));
}
public
function
setSupportedSymbol
()
{
$curl
=
new
Curl
();
$api
=
$this
->
base_url
.
'm/symbol'
;
$res
=
$curl
->
get
(
$api
,
false
);
//json
if
(
is_array
(
$res
)
&&
isset
(
$res
[
'state'
])
&&
1
==
$res
[
'state'
])
{
foreach
(
$res
as
$item
)
{
$this
->
redis
->
sadd
(
$this
->
supported_symbol
,
strtolower
(
$item
[
'symbol'
]));
}
}
}
public
function
setQuotation
()
{
$curl
=
new
Curl
();
$api
=
$this
->
base_url
.
'/m/allticker/'
.
time
();
$res
=
$curl
->
get
(
$api
,
false
);
if
(
is_array
(
$res
)
&&
isset
(
$res
[
'state'
])
&&
1
==
$res
[
'state'
])
{
$data
=
$res
[
'data'
];
foreach
(
$data
as
$key
=>
$item
)
{
$low
=
isset
(
$item
[
'low'
])
?
$item
[
'low'
]
:
0
;
$high
=
isset
(
$item
[
'high'
])
?
$item
[
'high'
]
:
0
;
$last
=
isset
(
$item
[
'close'
])
?
$item
[
'close'
]
:
0
;
$open
=
isset
(
$item
[
'open'
])
?
$item
[
'open'
]
:
0
;
$vol
=
isset
(
$item
[
'volume'
])
?
$item
[
'volume'
]
:
0
;
$cache_key
=
strtolower
(
$this
->
quotation_prefix
.
$item
[
'symbol'
]);
$this
->
redis
->
hmset
(
$cache_key
,
'low'
,
$low
,
'high'
,
$high
,
'last'
,
$last
,
'open'
,
$open
,
'vol'
,
$vol
);
$this
->
redis
->
sadd
(
$this
->
supported_symbol
,
$item
[
'symbol'
]);
}
}
}
}
common/service/exchange/Zhaobi.php
View file @
c63168a3
...
@@ -24,6 +24,7 @@ class Zhaobi extends Exchange implements ExchangeInterface
...
@@ -24,6 +24,7 @@ class Zhaobi extends Exchange implements ExchangeInterface
}
}
return
false
;
return
false
;
}
}
/**
/**
* 转化交易对为请求变量
* 转化交易对为请求变量
*
*
...
@@ -63,18 +64,9 @@ class Zhaobi extends Exchange implements ExchangeInterface
...
@@ -63,18 +64,9 @@ class Zhaobi extends Exchange implements ExchangeInterface
}
}
foreach
(
$ticker_temp
as
$val
)
{
foreach
(
$ticker_temp
as
$val
)
{
$key
=
$this
->
quotation_prefix
.
strtolower
(
$val
[
'symbol'
]);
$key
=
$this
->
quotation_prefix
.
strtolower
(
$val
[
'symbol'
]);
$this
->
redis
->
hmset
(
$key
,
'low'
,
$val
[
'low'
],
'high'
,
$val
[
'high'
],
'last'
,
$val
[
'last'
],
'open'
,
$val
[
'open'
],
'vol'
,
$val
[
'vol'
]);
$this
->
redis
->
hmset
(
$key
,
'low'
,
$val
[
'low'
],
'high'
,
$val
[
'high'
],
'last'
,
$val
[
'last'
],
'open'
,
$val
[
'open'
],
'vol'
,
$val
[
'vol'
]
,
'rmb'
,
$val
[
'lastrmb'
]
);
$this
->
redis
->
sadd
(
$this
->
supported_symbol
,
$val
[
'symbol'
]);
$this
->
redis
->
sadd
(
$this
->
supported_symbol
,
$val
[
'symbol'
]);
}
}
}
}
$api
=
$this
->
base_url
.
'/api/data/basecoinprice?base=CNY&coin=SFT&platform=zhaobi'
;
$content
=
$curl
->
get
(
$api
,
false
);
if
(
is_array
(
$content
)
&&
isset
(
$content
[
'code'
])
&&
(
200
==
$content
[
'code'
]))
{
$data
=
$content
[
'data'
][
0
];
$key
=
$this
->
quotation_prefix
.
'sftcny'
;
$this
->
redis
->
hmset
(
$key
,
'low'
,
$data
[
'value'
],
'high'
,
$data
[
'value'
],
'last'
,
$data
[
'value'
]);
$this
->
redis
->
sadd
(
$this
->
supported_symbol
,
'SFTCNY'
);
}
}
}
}
}
common/service/exchange/factory/ZhaobiBuilder.php
View file @
c63168a3
...
@@ -167,6 +167,22 @@ class ZhaobiBuilder extends FactoryService
...
@@ -167,6 +167,22 @@ class ZhaobiBuilder extends FactoryService
return
[
'code'
=>
$this
->
code
,
'notice'
=>
$data
];
return
[
'code'
=>
$this
->
code
,
'notice'
=>
$data
];
}
}
public
function
getDetail
(
$symbol
)
{
list
(
$low
,
$high
,
$close
,
$open
,
$vol
)
=
$this
->
redis
->
hmget
(
$this
->
quotation_prefix
.
strtolower
(
$symbol
),
'low'
,
'high'
,
'last'
,
'open'
,
'vol'
);
if
(
empty
(
$low
)
&&
empty
(
$high
)
&&
empty
(
$close
)
&&
empty
(
$open
)
&&
empty
(
$vol
))
{
return
[
'code'
=>
$this
->
code
,
'ticker'
=>
[]];
}
$ticker
=
[
'vol'
=>
$vol
,
'low'
=>
$low
,
'open'
=>
$open
,
'high'
=>
$high
,
'close'
=>
$close
];
return
[
'code'
=>
0
,
'ticker'
=>
$ticker
];
}
public
function
getHotTicker
(
$symbol
=
[])
public
function
getHotTicker
(
$symbol
=
[])
{
{
if
(
empty
(
$symbol
))
{
if
(
empty
(
$symbol
))
{
...
...
console/controllers/OrderController.php
0 → 100644
View file @
c63168a3
<?php
namespace
console\controllers
;
use
common\models\psources\CoinCrossChain
;
use
common\models\psources\CoinCTocTransfer
;
use
Yii
;
use
yii\console\Controller
;
use
common\service\chain33\Chain33Service
;
class
OrderController
extends
Controller
{
/**
* 自动交易
*
* @return array
*/
public
function
actionAutoOrder
(
$is_sell
,
$type
)
{
$redis
=
Yii
::
$app
->
redis_app
;
$model
=
CoinCTocTransfer
::
find
()
->
where
([
'send_result'
=>
"0"
,
'is_sell'
=>
(
int
)
$is_sell
,
'type'
=>
(
int
)
$type
,
'query_result'
=>
'0'
])
->
asArray
()
->
all
();
if
(
empty
(
$model
))
{
echo
date
(
'Y-m-d H:i:s'
)
.
'暂无交易计划'
.
PHP_EOL
;
return
0
;
}
$current_time
=
time
();
foreach
(
$model
as
$val
)
{
if
(
$val
[
'step'
]
>
1
)
{
$isExist
=
CoinCTocTransfer
::
find
()
->
where
([
'transfer_number'
=>
$val
[
'transfer_number'
]])
->
andWhere
([
'<'
,
'id'
,
(
int
)
$val
[
'id'
]])
->
orderBy
(
'id desc'
)
->
asArray
()
->
one
();
//上一步发送成功,未查询
if
(
'success'
!=
$isExist
[
'query_result'
]
&&
!
empty
(
$isExist
))
{
continue
;
}
}
$key
=
$val
[
'address'
]
.
'_'
.
$val
[
'is_sell'
]
.
'_'
.
$val
[
'token_name'
]
.
'_'
.
$val
[
'market_name'
];
$cache_transfering_time
=
$redis
->
hget
(
CoinCTocTransfer
::
C2C_ORDERING
,
$key
);
if
(
true
==
$cache_transfering_time
)
{
continue
;
}
$redis
->
hmset
(
CoinCTocTransfer
::
C2C_ORDERING
,
$key
,
$current_time
);
go
(
function
()
use
(
$val
,
$redis
,
$key
)
{
\Co
::
sleep
(
0.5
);
$transfer_url
=
$val
[
'transfer_url'
];
$transfer_url
=
explode
(
':'
,
$transfer_url
);
$node_params
=
[
'scheme'
=>
$transfer_url
[
0
],
'host'
=>
str_replace
(
'//'
,
''
,
$transfer_url
[
1
]),
'port'
=>
isset
(
$transfer_url
[
2
])
?
$transfer_url
[
2
]
:
''
,
];
$service
=
new
Chain33Service
(
$node_params
);
$sign_str
=
$val
[
'txhex'
];
$result
=
$service
->
sendTransaction
(
$sign_str
);
if
(
0
==
$result
[
'code'
])
{
$send_result
=
$result
[
'result'
];
$currentModel
=
CoinCTocTransfer
::
findOne
(
$val
[
'id'
]);
$currentModel
->
send_result
=
$send_result
;
$currentModel
->
msg
=
0
;
$currentModel
->
save
();
$redis
->
hdel
(
CoinCTocTransfer
::
C2C_ORDERING
,
$key
);
}
else
{
$currentModel
=
CoinCTocTransfer
::
findOne
(
$val
[
'id'
]);
$currentModel
->
msg
=
$result
[
'msg'
];
$currentModel
->
save
();
}
});
}
echo
date
(
'Y-m-d H:i:s'
)
.
'交易成功'
.
PHP_EOL
;
return
0
;
}
public
function
actionOrderStatus
()
{
$redis
=
Yii
::
$app
->
redis_app
;
$model
=
CoinCTocTransfer
::
find
()
->
where
([
'<>'
,
'send_result'
,
'0'
])
->
andWhere
([
'msg'
=>
'0'
])
->
asArray
()
->
all
();
if
(
empty
(
$model
))
{
echo
date
(
'Y-m-d H:i:s'
)
.
'暂无跨链交易计划'
.
PHP_EOL
;
return
0
;
}
//正式环境查询共识高度
//3步交易情况下需要做高度判断,2步交易无须判断
$node_params
=
[
'scheme'
=>
'https'
,
'host'
=>
'jiedian1.bityuan.com'
,
'port'
=>
8801
];
//测试环境查询共识高度
//2步交易情况下需要做高度判断
// $node_params = [
// 'scheme' => 'http',
// 'host' => '172.16.100.77',
// 'port' => 8801
// ];
$service
=
new
Chain33Service
(
$node_params
);
$result
=
$service
->
getHeight
();
$consensHeight
=
$result
[
'result'
][
'consensHeight'
];
$current_time
=
time
();
foreach
(
$model
as
$val
)
{
$key
=
$val
[
'address'
]
.
'_'
.
$val
[
'is_sell'
]
.
'_'
.
str_replace
(
'/'
,
''
,
strtoupper
(
$val
[
'token_name'
]))
.
'_'
.
str_replace
(
'/'
,
''
,
strtoupper
(
$val
[
'market_name'
]));
$node_params
=
$val
[
'transfer_url'
];
$node_params
=
explode
(
':'
,
$node_params
);
$node_params
=
[
'scheme'
=>
$node_params
[
0
],
'host'
=>
str_replace
(
'//'
,
''
,
$node_params
[
1
]),
'port'
=>
isset
(
$node_params
[
2
])
?
$node_params
[
2
]
:
''
];
$send_result
=
$val
[
'send_result'
];
$switch
=
true
;
$result
=
$this
->
queryTransaction
(
$node_params
,
$send_result
);
if
(
isset
(
$result
[
'result'
][
'actionName'
])
&&
'unknown'
==
$result
[
'result'
][
'actionName'
])
{
$redis
->
hdel
(
CoinCTocTransfer
::
C2C_ORDER_FAILED
,
$key
);
$query_result
=
'success'
;
$msg
=
'success'
;
$height
=
isset
(
$result
[
'result'
][
'height'
])
?
$result
[
'result'
][
'height'
]
:
0
;
goto
doEnd
;
}
else
if
(
isset
(
$result
[
'result'
][
'receipt'
][
'ty'
])
&&
2
==
$result
[
'result'
][
'receipt'
][
'ty'
])
{
$redis
->
hdel
(
CoinCTocTransfer
::
C2C_ORDER_FAILED
,
$key
);
$query_result
=
'success'
;
$msg
=
'success'
;
$height
=
isset
(
$result
[
'result'
][
'height'
])
?
$result
[
'result'
][
'height'
]
:
0
;
goto
doEnd
;
}
else
{
$cache_error_time
=
$redis
->
hget
(
CoinCTocTransfer
::
C2C_ORDER_FAILED
,
$key
);
if
(
false
==
$cache_error_time
)
{
$redis
->
hmset
(
CoinCTocTransfer
::
C2C_ORDER_FAILED
,
$key
,
$current_time
);
continue
;
}
if
((
$current_time
-
$cache_error_time
)
<
60
)
{
continue
;
}
$redis
->
hdel
(
CoinCTocTransfer
::
C2C_ORDER_FAILED
,
$key
);
if
(
-
1
==
$result
[
'code'
])
{
$msg
=
$result
[
'msg'
];
$query_result
=
$result
[
'code'
];
$switch
=
false
;
goto
doEnd
;
}
else
{
$query_result
=
'fail'
;
foreach
(
$result
[
'result'
][
'receipt'
][
'logs'
]
as
$log
)
{
if
(
is_array
(
$log
[
'log'
]))
continue
;
$msg
=
isset
(
$log
[
'log'
])
?
$log
[
'log'
]
:
'查询错误'
;
}
$switch
=
false
;
goto
doEnd
;
}
}
doEnd
:
//3步交易情况下需要做高度判断,2步交易注释IF判断
if
(
CoinCTocTransfer
::
CONSENSUE_YES
==
$val
[
'consensus'
]
&&
true
==
$switch
&&
isset
(
$height
)
&&
(
$consensHeight
<
$height
))
{
continue
;
}
$currentModel
=
CoinCTocTransfer
::
findOne
(
$val
[
'id'
]);
$currentModel
->
query_result
=
$query_result
;
$currentModel
->
msg
=
$msg
;
$currentModel
->
save
();
$model_c2c
=
CoinCTocTransfer
::
find
()
->
where
([
'transfer_number'
=>
$val
[
'transfer_number'
]])
->
asArray
()
->
all
();
$clear
=
true
;
foreach
(
$model_c2c
as
$record
)
{
if
(
'success'
!=
$record
[
'query_result'
])
{
$clear
=
false
;
}
}
if
(
$clear
)
{
$key
=
'C2C_'
.
$val
[
'is_sell'
]
.
'_'
.
str_replace
(
'/'
,
''
,
strtoupper
(
$val
[
'token_name'
]))
.
'_'
.
str_replace
(
'/'
,
''
,
strtoupper
(
$val
[
'market_name'
]));
$redis
->
hdel
(
$key
,
$val
[
'address'
]);
}
}
echo
date
(
'Y-m-d H:i:s'
)
.
'查询完毕'
.
PHP_EOL
;
return
0
;
}
protected
function
queryTransaction
(
$node_params
,
$send_result
)
{
static
$result
=
[];
$service
=
new
Chain33Service
(
$node_params
);
$result
=
$service
->
QueryTransaction
(
$send_result
);
if
(
isset
(
$result
[
'result'
][
'receipt'
])
&&
is_array
(
$result
[
'result'
][
'receipt'
][
'logs'
]))
{
foreach
(
$result
[
'result'
][
'receipt'
][
'logs'
]
as
$log
)
{
if
(
isset
(
$log
[
'tyName'
])
&&
'logerr'
==
strtolower
(
$log
[
'tyName'
]))
{
return
$result
;
}
}
}
if
(
isset
(
$result
[
'result'
][
'tx'
][
'next'
]))
{
$this
->
queryTransaction
(
$node_params
,
$result
[
'result'
][
'tx'
][
'next'
]);
}
return
$result
;
}
}
console/controllers/TickerController.php
View file @
c63168a3
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
namespace
console\controllers
;
namespace
console\controllers
;
use
common\service\exchange\ExchangeFactory
;
use
Yii
;
use
Yii
;
use
linslin\yii2\curl\Curl
;
use
linslin\yii2\curl\Curl
;
use
yii\console\Controller
;
use
yii\console\Controller
;
...
@@ -33,22 +34,32 @@ class TickerController extends Controller
...
@@ -33,22 +34,32 @@ class TickerController extends Controller
return
0
;
return
0
;
}
}
public
function
actionExchange
(
$exchange
)
{
$ticker_builder
=
ExchangeFactory
::
createExchange
(
$exchange
);
$ticker_builder
->
setQuotation
();
echo
date
(
'Y-m-d H:i:s'
)
.
$exchange
.
'更新成功'
.
PHP_EOL
;
return
0
;
}
public
function
actionCurrency
()
public
function
actionCurrency
()
{
{
$currency_model
=
CoinSupportedCurrency
::
find
()
->
groupBy
(
'currency_id'
)
->
all
();
$currency_model
=
CoinSupportedCurrency
::
find
()
->
groupBy
(
'currency_id'
)
->
all
();
$curl
=
new
Curl
();
$curl
=
new
Curl
();
foreach
(
$currency_model
as
$val
)
{
foreach
(
$currency_model
as
$val
)
{
if
(
1111
==
$val
->
currency
->
pj_id
)
continue
;
go
(
function
()
use
(
$val
,
$curl
)
{
go
(
function
()
use
(
$val
,
$curl
)
{
\Co
::
sleep
(
0.5
);
\Co
::
sleep
(
0.5
);
$response
=
$curl
->
setPostParams
([
$response
=
$curl
->
setPostParams
([
'erectDate'
=>
''
,
'erectDate'
=>
''
,
'nothing'
=>
''
,
'nothing'
=>
''
,
'pjname'
=>
$val
->
currency
->
pj_id
'pjname'
=>
$val
->
currency
->
pj_id
])
->
post
(
'http
://srh.bankofchina.com/search/whpj/search
.jsp'
);
])
->
post
(
'http
s://srh.bankofchina.com/search/whpj/search_cn
.jsp'
);
$response
=
iconv
(
'UTF-8'
,
'GBK//TRANSLIT'
,
$response
);
$response
=
iconv
(
'UTF-8'
,
'GBK//TRANSLIT'
,
$response
);
$html
=
HtmlDomParser
::
str_get_html
(
$response
);
$html
=
HtmlDomParser
::
str_get_html
(
$response
);
$div
=
(
$html
->
find
(
'div.BOC_main'
));
$div
=
(
$html
->
find
(
'div.BOC_main'
));
if
(
$div
->
find
(
'td'
))
{
foreach
(
$div
->
find
(
'td'
)
as
$key
=>
$e
)
{
foreach
(
$div
->
find
(
'td'
)
as
$key
=>
$e
)
{
if
(
$key
==
5
)
{
if
(
$key
==
5
)
{
$key
=
'quotation_boc_'
.
'CNY_'
.
$val
->
currency
->
symbol
;
$key
=
'quotation_boc_'
.
'CNY_'
.
$val
->
currency
->
symbol
;
...
@@ -56,6 +67,7 @@ class TickerController extends Controller
...
@@ -56,6 +67,7 @@ class TickerController extends Controller
Yii
::
$app
->
redis_currency
->
hmset
(
$key
,
'low'
,
$currency
,
'high'
,
$currency
,
'last'
,
$currency
,
'open'
,
$currency
);
Yii
::
$app
->
redis_currency
->
hmset
(
$key
,
'low'
,
$currency
,
'high'
,
$currency
,
'last'
,
$currency
,
'open'
,
$currency
);
}
}
}
}
}
});
});
}
}
echo
date
(
'Y-m-d H:i:s'
)
.
'计价货币更新成功'
.
PHP_EOL
;
echo
date
(
'Y-m-d H:i:s'
)
.
'计价货币更新成功'
.
PHP_EOL
;
...
...
wallet/controllers/IssueChainController.php
View file @
c63168a3
...
@@ -231,7 +231,7 @@ class IssueChainController extends BaseController
...
@@ -231,7 +231,7 @@ class IssueChainController extends BaseController
if
(
!
empty
(
$coin_model
))
{
if
(
!
empty
(
$coin_model
))
{
array_unshift
(
$symbol
,
$coin_model
->
name
);
array_unshift
(
$symbol
,
$coin_model
->
name
);
}
}
//
array_unshift($symbol, 'BTY');
array_unshift
(
$symbol
,
'BTY'
);
$val
->
tokens
=
$symbol
;
$val
->
tokens
=
$symbol
;
$val
->
platform_id
=
Yii
::
$app
->
params
[
'chain_nodes'
][
strtoupper
(
$val
->
platform
)][
'platform_id'
];
$val
->
platform_id
=
Yii
::
$app
->
params
[
'chain_nodes'
][
strtoupper
(
$val
->
platform
)][
'platform_id'
];
}
}
...
...
wallet/controllers/NoticeController.php
0 → 100644
View file @
c63168a3
<?php
namespace
wallet\controllers
;
use
common\models\pwallet\Notice
;
use
Yii
;
use
yii\data\Pagination
;
use
wallet\base\BaseController
;
class
NoticeController
extends
BaseController
{
public
function
actionIndex
()
{
$msg
=
'ok'
;
$code
=
0
;
$data
=
null
;
$page
=
Yii
::
$app
->
request
->
get
(
'page'
,
1
);
$size
=
Yii
::
$app
->
request
->
get
(
'size'
,
10
);
$group
=
Yii
::
$app
->
request
->
getGroup
();
if
(
'administrator'
==
$group
)
{
$platform_id
=
Yii
::
$app
->
request
->
get
(
'platform_id'
,
Yii
::
$app
->
request
->
getPlatformId
());
}
else
{
$platform_id
=
Yii
::
$app
->
request
->
getPlatformId
();
}
if
(
Yii
::
$app
->
request
->
isPost
)
{
$model
=
new
Notice
();
$model
->
setScenario
(
Notice
::
SCENARIOS_CREATE
);
$params
=
Yii
::
$app
->
request
->
post
();
$params
[
'platform_id'
]
=
$platform_id
;
$model
->
load
(
$params
,
''
);
if
(
!
$model
->
validate
())
{
$msg
=
$model
->
errors
;
$code
=
-
1
;
goto
doEnd
;
}
$model
->
save
();
goto
doEnd
;
}
if
(
Yii
::
$app
->
request
->
isGet
)
{
$status
=
Yii
::
$app
->
request
->
get
(
'status'
,
0
);
$type
=
Yii
::
$app
->
request
->
get
(
'type'
,
0
);
$query
=
Notice
::
find
()
->
select
(
'id, title, type, create_time'
)
->
where
([
'platform_id'
=>
$platform_id
])
->
asArray
();
if
(
false
!=
$status
)
{
$query
->
andWhere
([
'status'
=>
(
int
)
$status
]);
}
if
(
false
!=
$type
)
{
$query
->
andWhere
([
'type'
=>
(
int
)
$type
]);
}
$model
=
$query
->
offset
((
$page
-
1
)
*
$size
)
->
orderBy
(
'create_time'
)
->
limit
(
$size
)
->
asArray
()
->
all
();
$countQuery
=
clone
$query
;
$pages
=
new
Pagination
([
'totalCount'
=>
$countQuery
->
count
(),
'pageSize'
=>
$size
]);
$data
=
[
'list'
=>
$model
,
'page'
=>
[
'pageCount'
=>
$pages
->
pageCount
,
'pageSize'
=>
$size
,
'currentPage'
=>
$page
,
]
];
}
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
}
public
function
actionUpdate
()
{
$msg
=
'ok'
;
$code
=
0
;
$data
=
null
;
$group
=
Yii
::
$app
->
request
->
getGroup
();
if
(
'administrator'
==
$group
)
{
$platform_id
=
Yii
::
$app
->
request
->
get
(
'platform_id'
,
Yii
::
$app
->
request
->
getPlatformId
());
}
else
{
$platform_id
=
Yii
::
$app
->
request
->
getPlatformId
();
}
if
(
Yii
::
$app
->
request
->
isGet
)
{
$id
=
Yii
::
$app
->
request
->
get
(
'id'
);
$data
=
Notice
::
find
()
->
select
(
'id, title, content, author, status, type, is_top'
)
->
where
([
'platform_id'
=>
$platform_id
,
'id'
=>
$id
])
->
asArray
()
->
one
();
goto
doEnd
;
}
if
(
Yii
::
$app
->
request
->
isPut
)
{
$params
=
Yii
::
$app
->
request
->
post
();
$id
=
isset
(
$params
[
'id'
])
?
$params
[
'id'
]
:
null
;
if
(
false
==
$id
)
{
$msg
=
'参数错误'
;
$code
=
-
1
;
goto
doEnd
;
}
$model
=
Notice
::
findOne
(
$id
);
if
(
empty
(
$model
))
{
$msg
=
'数据错误'
;
$code
=
-
1
;
goto
doEnd
;
}
if
(
'administrator'
!=
$group
&&
$platform_id
!=
$model
->
platform_id
){
$msg
=
'无权操作'
;
$code
=
-
1
;
goto
doEnd
;
}
$model
->
setScenario
(
Notice
::
SCENARIOS_UPDATE
);
$model
->
load
(
$params
,
''
);
if
(
!
$model
->
validate
())
{
$msg
=
$model
->
errors
;
$code
=
-
1
;
goto
doEnd
;
}
$model
->
save
();
goto
doEnd
;
}
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
}
public
function
actionRemove
()
{
$msg
=
'ok'
;
$code
=
0
;
$data
=
null
;
$group
=
Yii
::
$app
->
request
->
getGroup
();
$platform_id
=
Yii
::
$app
->
request
->
getPlatformId
();
$id
=
Yii
::
$app
->
request
->
get
(
'id'
);
if
(
false
==
$id
)
{
$msg
=
'参数错误'
;
$code
=
-
1
;
goto
doEnd
;
}
if
(
Yii
::
$app
->
request
->
isDelete
)
{
$model
=
Notice
::
findOne
(
$id
);
if
(
'administrator'
!=
$group
&&
$platform_id
!=
$model
->
platform_id
){
$msg
=
'无权删除'
;
$code
=
-
1
;
goto
doEnd
;
}
if
(
!
$model
->
delete
())
{
$msg
=
'删除失败'
;
$code
=
-
1
;
goto
doEnd
;
}
}
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$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