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
28ce08f8
Commit
28ce08f8
authored
Oct 19, 2020
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/optimize' into develop
parents
8ecb71ac
eb00cc7c
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
298 additions
and
71 deletions
+298
-71
BaseController.php
api/base/BaseController.php
+33
-7
PlatformCoinsController.php
api/controllers/PlatformCoinsController.php
+82
-18
ExchangeBusiness.php
common/business/ExchangeBusiness.php
+26
-1
Tools.php
common/components/Tools.php
+28
-0
Bitnasdaq.php
common/service/exchange/Bitnasdaq.php
+17
-23
BitnasdaqBuilder.php
common/service/exchange/factory/BitnasdaqBuilder.php
+20
-18
AirDropController.php
console/controllers/AirDropController.php
+17
-1
IpExceptionController.php
console/controllers/IpExceptionController.php
+21
-3
UserController.php
wallet/controllers/UserController.php
+54
-0
No files found.
api/base/BaseController.php
View file @
28ce08f8
...
...
@@ -8,6 +8,7 @@
namespace
api\base
;
use
common\components\Tools
;
use
Yii
;
use
yii\web\Response
;
use
yii\web\Controller
;
...
...
@@ -52,13 +53,13 @@ class BaseController extends Controller
$this
->
currency_id
=
\Yii
::
$app
->
request
->
headers
->
get
(
'FZM-CURRENCY-ID'
);
}
$allow_list
=
array_unique
(
\Yii
::
$app
->
params
[
'allow_options_domain'
][
'allow_options_domain'
]);
$origin
=
\Yii
::
$app
->
request
->
headers
->
get
(
'Origin'
);
if
(
!
in_array
(
$origin
,
$allow_list
))
{
$origin
=
implode
(
','
,
$allow_list
);
}
$this
->
header
(
'Access-Control-Allow-Origin'
,
$origin
);
// $allow_list =
array_unique(\Yii::$app->params['allow_options_domain']['allow_options_domain']);
//
//
$origin = \Yii::$app->request->headers->get('Origin');
//
if (!in_array($origin, $allow_list)) {
//
$origin = implode(',', $allow_list);
//
}
//
$this->header('Access-Control-Allow-Origin', $origin);
$this
->
header
(
'Access-Control-Allow-Methods'
,
'POST,GET,OPTIONS,PUT,DELETE'
);
$this
->
header
(
'Access-Control-Allow-Credentials'
,
'true'
);
$this
->
header
(
'Access-Control-Allow-Headers'
,
'Authorization,FZM-REQUEST-OS,FZM-USER-IP,FZM-REQUEST-UUID,FZM-PLATFORM-ID,Content-Type,Content-Length'
);
...
...
@@ -66,6 +67,31 @@ class BaseController extends Controller
public
function
beforeAction
(
$action
)
{
$request_controller
=
Yii
::
$app
->
controller
->
id
;
$request_action
=
Yii
::
$app
->
controller
->
action
->
id
;
if
(
'platform-coins'
==
$request_controller
&&
'air-drop'
==
$request_action
)
{
$rawParams
=
Yii
::
$app
->
request
->
post
();
if
(
isset
(
$rawParams
[
'key'
]))
{
$DES
=
Yii
::
$app
->
des
;
$params
=
$DES
->
decrypt
(
$rawParams
[
'key'
]);
if
(
$params
==
false
)
{
return
[
'code'
=>
-
1
,
'data'
=>
null
,
'msg'
=>
'缺少必要的参数'
];
}
$rawBodyParams
=
json_decode
(
$params
,
true
);
Yii
::
$app
->
request
->
setBodyParams
(
$rawBodyParams
);
}
}
if
(
'ticker'
==
$request_controller
&&
'hot-ticker'
==
$request_action
)
{
$realip
=
Tools
::
getUserIp
();
$ip_list
=
file_get_contents
(
'http://172.16.0.230:8080/wallet_interface_ip_limit.txt'
);
$ip_arr
=
explode
(
"
\n
"
,
$ip_list
);
foreach
(
$ip_arr
as
$key
=>
$ip
)
{
if
(
$ip
==
$realip
)
{
return
false
;
}
}
}
$this
->
start
=
microtime
(
true
);
return
parent
::
beforeAction
(
$action
);
// TODO: Change the autogenerated stub
}
...
...
api/controllers/PlatformCoinsController.php
View file @
28ce08f8
...
...
@@ -9,15 +9,7 @@ use Yii;
class
PlatformCoinsController
extends
BaseController
{
/**
* 新增空投钱包
*
* @param string $platform_id
* @param string $platform_coins
* @return array
*/
public
function
actionIndex
()
public
function
actionAirDrop
()
{
$platform_id
=
Yii
::
$app
->
request
->
post
(
'platform_id'
,
''
);
$coins_address
=
Yii
::
$app
->
request
->
post
(
'platform_coins'
,
''
);
...
...
@@ -35,12 +27,15 @@ class PlatformCoinsController extends BaseController
}
$is_exist
=
true
;
if
(
41
==
$platform_id
)
{
if
(
41
!==
$platform_id
)
{
return
[
'code'
=>
-
1
,
'data'
=>
null
,
'msg'
=>
'缺少必要的参数'
];
}
$model
=
CoinPlatformCoins
::
find
()
->
where
([
'platform_id'
=>
$platform_id
,
'deviceCode'
=>
$deviceCode
])
->
one
();
if
(
!
$model
)
{
$is_exist
=
false
;
}
}
$item_array
=
[];
$to_address
=
''
;
...
...
@@ -56,11 +51,7 @@ class PlatformCoinsController extends BaseController
$isExistModel
->
save
();
continue
;
}
if
(
!
empty
(
$isExistModel
)
&&
strlen
(
$isExistModel
->
deviceCode
)
>
0
&&
$isExistModel
->
deviceCode
!==
$deviceCode
)
{
$isExistModel
->
deviceCode
=
$deviceCode
;
$isExistModel
->
save
();
continue
;
};
if
(
!
empty
(
$isExistModel
)
&&
$isExistModel
->
deviceCode
==
$deviceCode
)
{
continue
;
};
...
...
@@ -81,17 +72,90 @@ class PlatformCoinsController extends BaseController
return
[
'code'
=>
-
1
,
'data'
=>
null
,
'msg'
=>
'数据导入失败'
];
}
if
(
41
==
$platform_id
&&
false
==
$is_exist
)
{
if
(
false
==
$is_exist
)
{
$is_air_drop
=
CoinAirDropTransfer
::
find
()
->
where
([
'to_address'
=>
$to_address
,
'origin'
=>
CoinAirDropTransfer
::
ORIGIN_API
,
'type'
=>
CoinAirDropTransfer
::
TYPE_COINS
])
->
one
();
if
(
false
==
$is_air_drop
)
{
$model
=
new
CoinAirDropTransfer
();
$model
->
txhash
=
'0'
;
$model
->
msg
=
''
;
$model
->
to_address
=
$to_address
;
$model
->
coin_name
=
'EPC'
;
$model
->
amount
=
0.001
;
$model
->
amount
=
0.05
;
$model
->
origin
=
CoinAirDropTransfer
::
ORIGIN_API
;
$model
->
type
=
CoinAirDropTransfer
::
TYPE_COINS
;
$model
->
save
();
}
}
return
[
'code'
=>
0
,
'data'
=>
null
,
'msg'
=>
'数据导入成功'
];
}
/**
* 新增空投钱包
*
* @param string $platform_id
* @param string $platform_coins
* @return array
*/
public
function
actionIndex
()
{
$platform_id
=
Yii
::
$app
->
request
->
post
(
'platform_id'
,
''
);
$coins_address
=
Yii
::
$app
->
request
->
post
(
'platform_coins'
,
''
);
$type
=
Yii
::
$app
->
request
->
post
(
'type'
,
''
);
$header
=
Yii
::
$app
->
request
->
headers
;
$deviceCode
=
$header
[
'FZM-REQUEST-UUID'
]
??
null
;
if
(
empty
(
$platform_id
)
||
empty
(
$coins_address
)
||
empty
(
$type
))
{
return
[
'code'
=>
-
1
,
'data'
=>
null
,
'msg'
=>
'缺少必要的参数'
];
}
if
(
41
==
$platform_id
)
{
return
[
'code'
=>
-
1
,
'data'
=>
null
,
'msg'
=>
'缺少必要的参数'
];
}
if
(
empty
(
$deviceCode
))
{
return
[
'code'
=>
0
,
'data'
=>
null
,
'msg'
=>
'数据导入成功'
];
}
$item_array
=
[];
foreach
(
$coins_address
as
$item
)
{
$platform_coins_arr
=
explode
(
','
,
$item
);
$coin_name
=
$platform_coins_arr
[
0
];
$coins_address
=
$platform_coins_arr
[
1
];
if
(
empty
(
$coin_name
)
||
empty
(
$coins_address
))
continue
;
$isExistModel
=
CoinPlatformCoins
::
find
()
->
where
([
'coins_name'
=>
$coin_name
,
'coins_address'
=>
$coins_address
,
'platform_id'
=>
$platform_id
])
->
one
();
if
(
!
empty
(
$isExistModel
)
&&
empty
(
$isExistModel
->
deviceCode
))
{
$isExistModel
->
deviceCode
=
$deviceCode
;
$isExistModel
->
save
();
continue
;
}
// if (!empty($isExistModel) && strlen($isExistModel->deviceCode) > 0 && $isExistModel->deviceCode !== $deviceCode) {
// $isExistModel->deviceCode = $deviceCode;
// $isExistModel->save();
// continue;
// };
if
(
!
empty
(
$isExistModel
)
&&
$isExistModel
->
deviceCode
==
$deviceCode
)
{
continue
;
};
$item_array
[]
=
[
$coin_name
,
$coins_address
,
$type
,
$deviceCode
,
$platform_id
,
];
}
if
(
empty
(
$item_array
))
{
return
[
'code'
=>
0
,
'data'
=>
null
,
'msg'
=>
'数据导入成功'
];
}
$result
=
CoinPlatformCoins
::
batchImport
(
$item_array
);
if
(
!
$result
)
{
return
[
'code'
=>
-
1
,
'data'
=>
null
,
'msg'
=>
'数据导入失败'
];
}
return
[
'code'
=>
0
,
'data'
=>
null
,
'msg'
=>
'数据导入成功'
];
}
...
...
common/business/ExchangeBusiness.php
View file @
28ce08f8
...
...
@@ -86,6 +86,10 @@ class ExchangeBusiness
goto
doEnd
;
}
if
(
strtoupper
(
$tag
)
==
'USAT'
)
{
$tag
=
'USDT'
;
}
if
(
strtoupper
(
$tag
)
==
'DUSDT'
)
{
$quotation
=
[
'low'
=>
6.99
,
...
...
@@ -146,6 +150,16 @@ class ExchangeBusiness
goto
doEnd
;
}
if
(
strtoupper
(
$tag
)
==
'LHG'
)
{
$quotation
=
[
'low'
=>
0.1
,
'high'
=>
0.1
,
'last'
=>
0.1
,
'rmb'
=>
0.1
,
];
goto
doEnd
;
}
if
(
strtoupper
(
$tag
)
==
'GST'
||
strtoupper
(
$tag
)
==
'JNTK'
||
strtoupper
(
$tag
)
==
'SPT'
||
strtoupper
(
$tag
)
==
'STO'
||
strtoupper
(
$tag
)
==
'GM'
||
strtoupper
(
$tag
)
==
'BSTC'
||
strtoupper
(
$tag
)
==
'RYH'
||
strtoupper
(
$tag
)
==
'CNDT'
||
strtoupper
(
$tag
)
==
'WL'
||
strtoupper
(
$tag
)
==
'ETS'
||
strtoupper
(
$tag
)
==
'LIMS'
||
strtoupper
(
$tag
)
==
'AT'
||
strtoupper
(
$tag
)
==
'BTJ'
)
{
$quotation
=
[
'low'
=>
0
,
...
...
@@ -296,6 +310,17 @@ class ExchangeBusiness
goto
doEnd
;
}
if
(
in_array
(
strtoupper
(
$tag
),
[
'MBTC'
,
'METH'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"HuoBi"
);
if
(
'MBTC'
==
$tag
)
{
$quotation
=
$exchange
->
getTicker
(
'btc'
,
'usdt'
);
}
if
(
'METH'
==
$tag
)
{
$quotation
=
$exchange
->
getTicker
(
'eth'
,
'usdt'
);
}
goto
doEnd
;
}
if
(
in_array
(
strtoupper
(
$tag
),
[
'SJPY'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Boc"
);
$quotation
=
$exchange
->
getTicker
(
'CNY'
,
'JPY'
);
...
...
@@ -365,7 +390,7 @@ class ExchangeBusiness
$exchange
=
ExchangeFactory
::
createExchange
(
"Go"
);
$rate
=
$exchange
->
getTicker
(
"CNY"
,
"USD"
);
$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'
]))
{
if
(
in_array
(
strtoupper
(
$tag
),
[
'FOLI'
,
'CIC'
,
'KPC8'
,
'BVA'
,
'DAG'
,
'BNC'
,
'GHP'
,
'DRA'
,
'ETC'
,
'PAX'
,
'STH'
,
'XJH'
,
'SFT'
,
'TSC'
,
'SUM'
,
'USDW'
,
'FUT'
,
'MBTC'
,
'METH'
]))
{
$quotation
[
'usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'last'
]);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'last'
]
/
$cny_usd_rate
);
$quotation
[
'low'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'low'
]);
...
...
common/components/Tools.php
View file @
28ce08f8
...
...
@@ -179,4 +179,31 @@ class Tools
// Return the array elements
return
$array
;
}
/**
* 不同环境下获取真实的IP
*/
public
static
function
getUserIp
()
{
// 判断服务器是否允许$_SERVER
if
(
isset
(
$_SERVER
))
{
if
(
isset
(
$_SERVER
[
'HTTP_X_FORWARDED_FOR'
]))
{
$realip
=
$_SERVER
[
'HTTP_X_FORWARDED_FOR'
];
}
elseif
(
isset
(
$_SERVER
[
'HTTP_CLIENT_IP'
]))
{
$realip
=
$_SERVER
[
'HTTP_CLIENT_IP'
];
}
else
{
$realip
=
$_SERVER
[
'REMOTE_ADDR'
];
}
}
else
{
// 不允许就使用getenv获取
if
(
getenv
(
"HTTP_X_FORWARDED_FOR"
))
{
$realip
=
getenv
(
"HTTP_X_FORWARDED_FOR"
);
}
elseif
(
getenv
(
"HTTP_CLIENT_IP"
))
{
$realip
=
getenv
(
"HTTP_CLIENT_IP"
);
}
else
{
$realip
=
getenv
(
"REMOTE_ADDR"
);
}
}
return
$realip
;
}
}
\ No newline at end of file
common/service/exchange/Bitnasdaq.php
View file @
28ce08f8
...
...
@@ -15,7 +15,7 @@ class Bitnasdaq extends Exchange implements ExchangeInterface
{
protected
$supported_symbol
=
'supported_symbol_bitnasdaq'
;
protected
$quotation_prefix
=
'quotation_bitnasdaq_'
;
protected
$base_url
=
'https://
www.bitnasdaq.com
/'
;
protected
$base_url
=
'https://
openapi.bitnasdaq.pro
/'
;
public
function
formatSymbol
(
$tag
=
'BTC'
,
$aim
=
'USDT'
)
{
...
...
@@ -24,35 +24,29 @@ class Bitnasdaq extends Exchange implements ExchangeInterface
public
function
setSupportedSymbol
()
{
$curl
=
new
Curl
();
$api
=
$this
->
base_url
.
'/api/v1/ticker/24hr'
;
$res
=
$curl
->
get
(
$api
,
false
);
//json
if
(
is_array
(
$res
))
{
foreach
(
$res
as
$item
)
{
$this
->
redis
->
sadd
(
$this
->
supported_symbol
,
strtolower
(
$item
[
'symbol'
]));
}
}
}
public
function
setQuotation
()
{
$curl
=
new
Curl
();
$api
=
$this
->
base_url
.
'/
app/tradeMarket/coinPrice
'
;
$api
=
$this
->
base_url
.
'/
open/api/get_allticker
'
;
$res
=
$curl
->
get
(
$api
,
false
);
if
(
is_array
(
$res
)
&&
isset
(
$res
[
'obj'
]))
{
$data
=
$res
[
'obj'
];
if
(
is_array
(
$res
)
&&
isset
(
$res
[
'data'
]))
{
$data
=
$res
[
'data'
][
'ticker'
];
foreach
(
$data
as
$key
=>
$item
)
{
if
(
strpos
(
strtoupper
(
$key
),
'_CNYT'
)
!==
false
)
{
continue
;
}
$low
=
isset
(
$item
[
'minPrice'
])
?
$item
[
'minPrice
'
]
:
0
;
$high
=
isset
(
$item
[
'maxPrice'
])
?
$item
[
'maxPrice
'
]
:
0
;
$last
=
isset
(
$item
[
'currentExchangPrice'
])
?
$item
[
'currentExchangPrice
'
]
:
0
;
$open
=
isset
(
$item
[
'openPrice'
])
?
$item
[
'openPric
e'
]
:
0
;
$vol
=
isset
(
$item
[
'transactionSum'
])
?
$item
[
'transactionSum'
]
:
0
;
$cache_key
=
strtolower
(
$this
->
quotation_prefix
.
str_replace
(
'_'
,
''
,
$key
)
);
$this
->
redis
->
hmset
(
$cache_key
,
'low'
,
$low
,
'high'
,
$high
,
'last'
,
$last
,
'open'
,
$open
,
'vol'
,
$vol
);
$this
->
redis
->
sadd
(
$this
->
supported_symbol
,
strtoupper
(
str_replace
(
'_'
,
''
,
$key
)));
#if (in_array(strtoupper($item['symbol']), ['BNCUSAT', 'BTCUSAT', 'ETCUSAT', 'ETHUSAT', 'GHPUSAT', 'LTCUSAT', 'BNCUSDT']))
{
$low
=
isset
(
$item
[
'low'
])
?
$item
[
'low'
]
:
0
;
$high
=
isset
(
$item
[
'high'
])
?
$item
[
'high'
]
:
0
;
$last
=
isset
(
$item
[
'last'
])
?
$item
[
'last
'
]
:
0
;
$open
=
isset
(
$item
[
'last'
])
?
$item
[
'last
'
]
:
0
;
$vol
=
isset
(
$item
[
'vol'
])
?
$item
[
'vol
'
]
:
0
;
$change
=
isset
(
$item
[
'rose'
])
?
$item
[
'ros
e'
]
:
0
;
$cache_key
=
strtolower
(
$this
->
quotation_prefix
.
$item
[
'symbol'
])
;
$this
->
redis
->
hmset
(
$cache_key
,
'low'
,
$low
,
'high'
,
$high
,
'last'
,
$last
,
'open'
,
$open
,
'vol'
,
$vol
,
'change'
,
$change
);
$this
->
redis
->
sadd
(
$this
->
supported_symbol
,
strtoupper
(
$item
[
'symbol'
])
);
#}
}
}
}
...
...
common/service/exchange/factory/BitnasdaqBuilder.php
View file @
28ce08f8
...
...
@@ -62,21 +62,22 @@ class BitnasdaqBuilder extends FactoryService
$ticker
=
[];
foreach
(
$keys
as
$val
)
{
foreach
(
$this
->
basic_coin
as
$k
=>
$coin
)
{
$explode_arr
=
explode
(
strtoupper
(
$coin
),
strtoupper
(
$val
));
$temp_symbol
=
str_replace
(
'USAT'
,
'USDT'
,
$val
);
$explode_arr
=
explode
(
strtoupper
(
$coin
),
strtoupper
(
$temp_symbol
));
if
(
2
==
count
(
$explode_arr
)
&&
empty
(
$explode_arr
[
1
]))
{
if
(
false
!=
$condition
)
{
list
(
$low
,
$high
,
$close
,
$open
,
$vol
)
=
$this
->
redis_ticker
->
hmget
(
$this
->
quotation_prefix
.
strtoupper
(
$val
),
'low'
,
'high'
,
'last'
,
'open'
,
'vol
'
);
list
(
$low
,
$high
,
$close
,
$open
,
$vol
,
$change
)
=
$this
->
redis_ticker
->
hmget
(
$this
->
quotation_prefix
.
strtoupper
(
$val
),
'low'
,
'high'
,
'last'
,
'open'
,
'vol'
,
'change
'
);
}
else
{
list
(
$low
,
$high
,
$close
,
$open
,
$vol
)
=
$this
->
redis
->
hmget
(
$this
->
quotation_prefix
.
strtolower
(
$val
),
'low'
,
'high'
,
'last'
,
'open'
,
'vol
'
);
list
(
$low
,
$high
,
$close
,
$open
,
$vol
,
$change
)
=
$this
->
redis
->
hmget
(
$this
->
quotation_prefix
.
strtolower
(
$val
),
'low'
,
'high'
,
'last'
,
'open'
,
'vol'
,
'change
'
);
}
$temp
=
[];
$temp
[
'symbol'
]
=
strtoupper
(
$explode_arr
[
0
])
.
'/
'
.
$coin
;
$temp
[
'symbol'
]
=
strtoupper
(
$explode_arr
[
0
])
.
'/
USAT'
;
$temp
[
'currency'
]
=
strtoupper
(
$explode_arr
[
0
]);
$temp
[
'base_currency'
]
=
strtoupper
(
$coin
)
;
$temp
[
'base_currency'
]
=
'USAT'
;
$temp
[
'close'
]
=
rtrim
(
sprintf
(
'%.8f'
,
floatval
(
$close
)),
'0'
);
$temp
[
'close_usd'
]
=
rtrim
(
sprintf
(
'%.6f'
,
floatval
(
$close
*
$this
->
basic_price
[
$coin
][
'usd'
])),
'0'
);
$temp
[
'close_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$close
*
$this
->
basic_price
[
$coin
][
'rmb'
]);
$temp
[
'change'
]
=
(
f
alse
==
$open
)
?
0
:
(
float
)
sprintf
(
"%0.2f"
,
(
$close
-
$open
)
/
$open
*
100
);
$temp
[
'change'
]
=
(
f
loat
)
sprintf
(
"%0.2f"
,
$change
*
100
);
$temp
[
'high_usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$high
*
$this
->
basic_price
[
$coin
][
'usd'
]);
$temp
[
'low_usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$low
*
$this
->
basic_price
[
$coin
][
'usd'
]);
$temp
[
'high_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$high
*
$this
->
basic_price
[
$coin
][
'rmb'
]);
...
...
@@ -106,28 +107,29 @@ class BitnasdaqBuilder extends FactoryService
$ticker
=
[];
for
(
$i
=
0
;
$i
<
$len
;
$i
++
)
{
$symbol
=
$this
->
redis
->
lindex
(
$this
->
supported_symbol_list
,
$i
);
list
(
$close
,
$open
,
$low
,
$high
,
$vol
)
=
$this
->
redis
->
hmget
(
$this
->
quotation_prefix
.
strtolower
(
$symbol
),
'last'
,
'open'
,
'low'
,
'high'
,
'vol
'
);
list
(
$close
,
$open
,
$low
,
$high
,
$vol
,
$change
)
=
$this
->
redis
->
hmget
(
$this
->
quotation_prefix
.
strtolower
(
$symbol
),
'last'
,
'open'
,
'low'
,
'high'
,
'vol'
,
'change
'
);
if
(
'0.00000000'
==
$close
)
continue
;
$temp
=
[];
$temp
[
'symbol'
]
=
strtoupper
(
$symbol
);
$temp
[
'close'
]
=
$close
;
foreach
(
$this
->
basic_coin
as
$k
=>
$coin
)
{
$explode_arr
=
explode
(
strtoupper
(
$coin
),
strtoupper
(
$symbol
));
if
(
2
==
count
(
$explode_arr
)
&&
empty
(
$explode_arr
[
1
]))
{
$temp
[
'close_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$close
*
$this
->
basic_price
[
$coin
][
'rmb'
]);
}
}
//为什么要加close_rmb作为排序
// foreach ($this->basic_coin as $k => $coin) {
// $explode_arr = explode(strtoupper($coin), strtoupper($symbol));
// if (2 == count($explode_arr) && empty($explode_arr[1])) {
// $temp['close_rmb'] = (float)sprintf("%0.4f", $close * $this->basic_price[$coin]['rmb']);
// }
// }
$temp
[
'low'
]
=
$low
;
$temp
[
'high'
]
=
$high
;
$temp
[
'open'
]
=
$open
;
$temp
[
'vol'
]
=
$vol
;
$temp
[
'change'
]
=
(
0
==
$open
)
?
0
:
(
float
)
sprintf
(
"%0.2f"
,
(
$close
-
$open
)
/
$open
*
100
);
$temp
[
'change'
]
=
(
float
)
sprintf
(
"%0.2f"
,
$change
);
array_push
(
$ticker
,
$temp
);
$key
=
$this
->
quotation_prefix
.
strtoupper
(
$symbol
);
$this
->
redis_ticker
->
hmset
(
$key
,
'low'
,
$low
,
'high'
,
$high
,
'last'
,
$close
,
'open'
,
$open
,
'vol'
,
$vol
);
$this
->
redis_ticker
->
hmset
(
$key
,
'low'
,
$low
,
'high'
,
$high
,
'last'
,
$close
,
'open'
,
$open
,
'vol'
,
$vol
,
'change'
,
$change
);
}
$ticker_sort_close
=
Tools
::
arraySort
(
$ticker
,
'close
_rmb
'
);
$ticker_sort_close
=
Tools
::
arraySort
(
$ticker
,
'close'
);
$this
->
redis_ticker
->
del
(
$this
->
supported_symbol_close_asc
);
$this
->
redis_ticker
->
del
(
$this
->
supported_symbol_close_desc
);
foreach
(
$ticker_sort_close
as
$val
)
{
...
...
@@ -152,7 +154,7 @@ class BitnasdaqBuilder extends FactoryService
$ticker
=
[];
foreach
(
$symbol
as
$val
)
{
list
(
$low
,
$high
,
$close
,
$open
,
$
vol
)
=
$this
->
redis
->
hmget
(
$this
->
quotation_prefix
.
strtolower
(
$val
),
'low'
,
'high'
,
'last'
,
'open
'
,
'vol'
);
list
(
$low
,
$high
,
$close
,
$open
,
$
change
,
$vol
)
=
$this
->
redis
->
hmget
(
$this
->
quotation_prefix
.
strtolower
(
$val
),
'low'
,
'high'
,
'last'
,
'open'
,
'change
'
,
'vol'
);
$explode_arr
=
explode
(
'usdt'
,
$val
);
$temp
=
[];
$temp
[
'symbol'
]
=
strtoupper
(
$explode_arr
[
0
])
.
'/USDT'
;
...
...
@@ -161,7 +163,7 @@ class BitnasdaqBuilder extends FactoryService
$temp
[
'close'
]
=
(
float
)
sprintf
(
"%0.6f"
,
$close
);
$temp
[
'close_usd'
]
=
(
float
)
sprintf
(
"%0.6f"
,
$close
*
$this
->
basic_price
[
'USDT'
][
'usd'
]);
$temp
[
'close_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$close
*
$this
->
basic_price
[
'USDT'
][
'rmb'
]);
$temp
[
'change'
]
=
(
0
==
$open
)
?
0
:
(
float
)
sprintf
(
"%0.2f"
,
(
$close
-
$open
)
/
$open
*
100
);
$temp
[
'change'
]
=
(
float
)
sprintf
(
"%0.2f"
,
$change
*
100
);
$temp
[
'high_usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$high
*
$this
->
basic_price
[
'USDT'
][
'usd'
]);
$temp
[
'low_usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$low
*
$this
->
basic_price
[
'USDT'
][
'usd'
]);
$temp
[
'high_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$high
*
$this
->
basic_price
[
'USDT'
][
'rmb'
]);
...
...
console/controllers/AirDropController.php
View file @
28ce08f8
...
...
@@ -274,6 +274,7 @@ class AirDropController extends Controller
$service
=
new
Chain33Service
(
$node_params
);
$execer
=
'coins'
;
$createRawTransaction
=
$service
->
createRawTransaction
(
$to
,
$amount
,
$fee
,
$note
,
$execer
);
$privkey
=
'72c3879f1f9b523f266a9545b69bd41c0251483a93e21e348e85118afe17a5e2'
;
}
if
(
CoinAirDropTransfer
::
TYPE_TOKEN
==
$val
[
'type'
]
&&
CoinAirDropTransfer
::
ORIGIN_IMPORT
==
$val
[
'origin'
])
{
$node_params
=
Yii
::
$app
->
params
[
'chain_parallel'
][
'parallel'
];
...
...
@@ -282,6 +283,7 @@ class AirDropController extends Controller
$isToken
=
true
;
$tokenSymbol
=
$val
[
'coin_name'
];
$createRawTransaction
=
$service
->
createTokenRawTransaction
(
$to
,
$amount
,
$isToken
,
$tokenSymbol
,
$fee
,
$note
,
$execer
);
$privkey
=
'72c3879f1f9b523f266a9545b69bd41c0251483a93e21e348e85118afe17a5e2'
;
}
if
(
CoinAirDropTransfer
::
TYPE_COINS
==
$val
[
'type'
]
&&
CoinAirDropTransfer
::
ORIGIN_API
==
$val
[
'origin'
])
{
$node_params
=
[
...
...
@@ -294,6 +296,7 @@ class AirDropController extends Controller
$isToken
=
false
;
$tokenSymbol
=
$val
[
'coin_name'
];
$createRawTransaction
=
$service
->
createTokenRawTransaction
(
$to
,
$amount
,
$isToken
,
$tokenSymbol
,
$fee
,
$note
,
$execer
);
$privkey
=
'c71d22278ba8e524593e69f0c4afbd1e21a5151fddd32c7e84c354ea3a31f07a'
;
}
if
(
isset
(
$createRawTransaction
[
'code'
])
&&
0
!=
$createRawTransaction
[
'code'
])
{
...
...
@@ -303,7 +306,7 @@ class AirDropController extends Controller
}
$txHex
=
$createRawTransaction
[
'result'
];
$privkey
=
'72c3879f1f9b523f266a9545b69bd41c0251483a93e21e348e85118afe17a5e2'
;
$expire
=
'1m'
;
$signRawTx
=
$service
->
signRawTx
(
$privkey
,
$txHex
,
$expire
);
...
...
@@ -331,4 +334,16 @@ class AirDropController extends Controller
}
return
0
;
}
/**
* fix失败空投
* @return
*/
public
function
actionFix
()
{
$ids
=
AirDropApplyRecord
::
find
()
->
select
(
'id'
)
->
where
([
'draw_status'
=>
AirDropApplyRecord
::
STATUS_DRAW_FAIL
])
->
asArray
()
->
all
();
$ids
=
array_column
(
$ids
,
'id'
);
if
(
empty
(
$ids
))
return
0
;
AirDropApplyRecord
::
updateAll
([
'draw_status'
=>
AirDropApplyRecord
::
STATUS_DRAWING
],
[
'id'
=>
$ids
]);
}
}
\ No newline at end of file
console/controllers/IpExceptionController.php
View file @
28ce08f8
...
...
@@ -13,14 +13,13 @@ class IpExceptionController extends Controller
$elastic
=
new
Elastic
(
'106.15.39.94:9200'
);
$params
=
[
'index'
=>
'bwallet_access'
,
'type'
=>
'doc'
,
'body'
=>
[
"size"
=>
0
,
"aggs"
=>
[
"ips"
=>
[
"terms"
=>
[
"field"
=>
"clientip.keyword"
,
"size"
=>
20
0
,
"size"
=>
5
0
,
"order"
=>
[
"_count"
=>
"desc"
]
...
...
@@ -65,17 +64,35 @@ class IpExceptionController extends Controller
if
(
empty
(
$buckets
))
{
return
false
;
}
$redis_ticker
=
\Yii
::
$app
->
redis_es
;
$limit
=
\Yii
::
$app
->
params
[
'api_ip_limit'
][
'limit'
];
$white_list
=
\Yii
::
$app
->
params
[
'api_ip_limit'
][
'white_list'
];
$ips
=
''
;
foreach
(
$buckets
as
$key
=>
$val
)
{
if
(
in_array
(
$val
[
'key'
],
$white_list
))
continue
;
if
(
$val
[
'doc_count'
]
>
$limit
){
if
(
!
isset
(
$val
[
'request'
][
'buckets'
]))
continue
;
foreach
(
$val
[
'request'
][
'buckets'
]
as
$b
=>
$item
)
{
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'
]
.
','
;
}
}
}
}
$ips
=
substr
(
$ips
,
0
,
-
1
);
if
(
!
empty
(
$ips
))
{
$file
=
fopen
(
"/data_wallet/static/wallet_interface_ip_limit.txt"
,
"w"
);
$ip_arr
=
explode
(
','
,
$ips
);
foreach
(
$ip_arr
as
$key
=>
$ip
)
{
fwrite
(
$file
,
$ip
.
"
\n
"
);
}
fclose
(
$file
);
};
return
false
;
}
}
\ No newline at end of file
wallet/controllers/UserController.php
View file @
28ce08f8
...
...
@@ -305,4 +305,57 @@ class UserController extends BaseController
}
return
[
'code'
=>
1
,
'data'
=>
$result
[
'msg'
],
'msg'
=>
'success'
];
}
public
function
actionEditPwd
()
{
if
(
!
Yii
::
$app
->
request
->
isPut
)
{
$this
->
msg
=
'请求方式错误'
;
$this
->
code
=
-
1
;
goto
doEnd
;
}
$token
=
Yii
::
$app
->
request
->
headers
->
get
(
'Token'
);
$user_info
=
Admin
::
verfication
(
$token
);
if
(
0
!=
$user_info
[
'code'
])
{
$this
->
msg
=
$user_info
[
'data'
];
$this
->
code
=
-
1
;
goto
doEnd
;
}
$user_info
=
(
array
)
$user_info
[
'data'
];
$user
=
Admin
::
findOne
(
$user_info
[
'uid'
]);
$old_password
=
Yii
::
$app
->
request
->
post
(
'old_password'
,
null
);
$new_password
=
Yii
::
$app
->
request
->
post
(
'new_password'
,
null
);
$new_password1
=
Yii
::
$app
->
request
->
post
(
'new_password1'
,
null
);
if
(
!
$old_password
)
{
$this
->
msg
=
"请输入原始密码"
;
$this
->
code
=
-
1
;
goto
doEnd
;
}
if
(
!
$new_password
)
{
$this
->
msg
=
"请输入新密码"
;
$this
->
code
=
-
1
;
goto
doEnd
;
}
if
(
!
$new_password1
)
{
$this
->
msg
=
"请再次输入新密码"
;
$this
->
code
=
-
1
;
goto
doEnd
;
}
if
(
$new_password
!=
$new_password1
)
{
$this
->
msg
=
"新密码输入不一致,请重新输入"
;
$this
->
code
=
-
1
;
goto
doEnd
;
}
if
(
!
Yii
::
$app
->
security
->
validatePassword
(
$old_password
,
$user
->
password
))
{
$this
->
msg
=
"原始密码错误,请重新输入"
;
$this
->
code
=
-
1
;
goto
doEnd
;
}
$user
->
setPassword
(
$new_password
);
$user
->
save
();
doEnd
:
return
[
'code'
=>
$this
->
code
,
'msg'
=>
$this
->
msg
,
'data'
=>
$this
->
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