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
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
309 additions
and
82 deletions
+309
-82
BaseController.php
api/base/BaseController.php
+33
-7
PlatformCoinsController.php
api/controllers/PlatformCoinsController.php
+91
-27
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
+23
-5
UserController.php
wallet/controllers/UserController.php
+54
-0
No files found.
api/base/BaseController.php
View file @
28ce08f8
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
namespace
api\base
;
namespace
api\base
;
use
common\components\Tools
;
use
Yii
;
use
Yii
;
use
yii\web\Response
;
use
yii\web\Response
;
use
yii\web\Controller
;
use
yii\web\Controller
;
...
@@ -52,13 +53,13 @@ class BaseController extends Controller
...
@@ -52,13 +53,13 @@ class BaseController extends Controller
$this
->
currency_id
=
\Yii
::
$app
->
request
->
headers
->
get
(
'FZM-CURRENCY-ID'
);
$this
->
currency_id
=
\Yii
::
$app
->
request
->
headers
->
get
(
'FZM-CURRENCY-ID'
);
}
}
$allow_list
=
array_unique
(
\Yii
::
$app
->
params
[
'allow_options_domain'
][
'allow_options_domain'
]);
// $allow_list =
array_unique(\Yii::$app->params['allow_options_domain']['allow_options_domain']);
//
$origin
=
\Yii
::
$app
->
request
->
headers
->
get
(
'Origin'
);
//
$origin = \Yii::$app->request->headers->get('Origin');
if
(
!
in_array
(
$origin
,
$allow_list
))
{
//
if (!in_array($origin, $allow_list)) {
$origin
=
implode
(
','
,
$allow_list
);
//
$origin = implode(',', $allow_list);
}
//
}
$this
->
header
(
'Access-Control-Allow-Origin'
,
$origin
);
//
$this->header('Access-Control-Allow-Origin', $origin);
$this
->
header
(
'Access-Control-Allow-Methods'
,
'POST,GET,OPTIONS,PUT,DELETE'
);
$this
->
header
(
'Access-Control-Allow-Methods'
,
'POST,GET,OPTIONS,PUT,DELETE'
);
$this
->
header
(
'Access-Control-Allow-Credentials'
,
'true'
);
$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'
);
$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
...
@@ -66,6 +67,31 @@ class BaseController extends Controller
public
function
beforeAction
(
$action
)
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
);
$this
->
start
=
microtime
(
true
);
return
parent
::
beforeAction
(
$action
);
// TODO: Change the autogenerated stub
return
parent
::
beforeAction
(
$action
);
// TODO: Change the autogenerated stub
}
}
...
...
api/controllers/PlatformCoinsController.php
View file @
28ce08f8
...
@@ -9,6 +9,88 @@ use Yii;
...
@@ -9,6 +9,88 @@ use Yii;
class
PlatformCoinsController
extends
BaseController
class
PlatformCoinsController
extends
BaseController
{
{
public
function
actionAirDrop
()
{
$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
(
empty
(
$deviceCode
))
{
return
[
'code'
=>
0
,
'data'
=>
null
,
'msg'
=>
'数据导入成功'
];
}
$is_exist
=
true
;
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
=
''
;
foreach
(
$coins_address
as
$item
)
{
$platform_coins_arr
=
explode
(
','
,
$item
);
$coin_name
=
$platform_coins_arr
[
0
];
$coins_address
=
$platform_coins_arr
[
1
];
$to_address
=
$coins_address
;
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
)
&&
$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'
=>
'数据导入失败'
];
}
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.05
;
$model
->
origin
=
CoinAirDropTransfer
::
ORIGIN_API
;
$model
->
type
=
CoinAirDropTransfer
::
TYPE_COINS
;
$model
->
save
();
}
}
return
[
'code'
=>
0
,
'data'
=>
null
,
'msg'
=>
'数据导入成功'
];
}
/**
/**
* 新增空投钱包
* 新增空投钱包
*
*
...
@@ -30,25 +112,19 @@ class PlatformCoinsController extends BaseController
...
@@ -30,25 +112,19 @@ class PlatformCoinsController extends BaseController
return
[
'code'
=>
-
1
,
'data'
=>
null
,
'msg'
=>
'缺少必要的参数'
];
return
[
'code'
=>
-
1
,
'data'
=>
null
,
'msg'
=>
'缺少必要的参数'
];
}
}
if
(
empty
(
$deviceCode
)
)
{
if
(
41
==
$platform_id
)
{
return
[
'code'
=>
0
,
'data'
=>
null
,
'msg'
=>
'数据导入成功
'
];
return
[
'code'
=>
-
1
,
'data'
=>
null
,
'msg'
=>
'缺少必要的参数
'
];
}
}
$is_exist
=
true
;
if
(
empty
(
$deviceCode
))
{
if
(
41
==
$platform_id
)
{
return
[
'code'
=>
0
,
'data'
=>
null
,
'msg'
=>
'数据导入成功'
];
$model
=
CoinPlatformCoins
::
find
()
->
where
([
'platform_id'
=>
$platform_id
,
'deviceCode'
=>
$deviceCode
])
->
one
();
if
(
!
$model
)
{
$is_exist
=
false
;
}
}
}
$item_array
=
[];
$item_array
=
[];
$to_address
=
''
;
foreach
(
$coins_address
as
$item
)
{
foreach
(
$coins_address
as
$item
)
{
$platform_coins_arr
=
explode
(
','
,
$item
);
$platform_coins_arr
=
explode
(
','
,
$item
);
$coin_name
=
$platform_coins_arr
[
0
];
$coin_name
=
$platform_coins_arr
[
0
];
$coins_address
=
$platform_coins_arr
[
1
];
$coins_address
=
$platform_coins_arr
[
1
];
$to_address
=
$coins_address
;
if
(
empty
(
$coin_name
)
||
empty
(
$coins_address
))
continue
;
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
();
$isExistModel
=
CoinPlatformCoins
::
find
()
->
where
([
'coins_name'
=>
$coin_name
,
'coins_address'
=>
$coins_address
,
'platform_id'
=>
$platform_id
])
->
one
();
if
(
!
empty
(
$isExistModel
)
&&
empty
(
$isExistModel
->
deviceCode
))
{
if
(
!
empty
(
$isExistModel
)
&&
empty
(
$isExistModel
->
deviceCode
))
{
...
@@ -56,11 +132,11 @@ class PlatformCoinsController extends BaseController
...
@@ -56,11 +132,11 @@ class PlatformCoinsController extends BaseController
$isExistModel
->
save
();
$isExistModel
->
save
();
continue
;
continue
;
}
}
if
(
!
empty
(
$isExistModel
)
&&
strlen
(
$isExistModel
->
deviceCode
)
>
0
&&
$isExistModel
->
deviceCode
!==
$deviceCode
)
{
//
if (!empty($isExistModel) && strlen($isExistModel->deviceCode) > 0 && $isExistModel->deviceCode !== $deviceCode) {
$isExistModel
->
deviceCode
=
$deviceCode
;
//
$isExistModel->deviceCode = $deviceCode;
$isExistModel
->
save
();
//
$isExistModel->save();
continue
;
//
continue;
};
//
};
if
(
!
empty
(
$isExistModel
)
&&
$isExistModel
->
deviceCode
==
$deviceCode
)
{
if
(
!
empty
(
$isExistModel
)
&&
$isExistModel
->
deviceCode
==
$deviceCode
)
{
continue
;
continue
;
};
};
...
@@ -81,18 +157,6 @@ class PlatformCoinsController extends BaseController
...
@@ -81,18 +157,6 @@ class PlatformCoinsController extends BaseController
return
[
'code'
=>
-
1
,
'data'
=>
null
,
'msg'
=>
'数据导入失败'
];
return
[
'code'
=>
-
1
,
'data'
=>
null
,
'msg'
=>
'数据导入失败'
];
}
}
if
(
41
==
$platform_id
&&
false
==
$is_exist
)
{
$model
=
new
CoinAirDropTransfer
();
$model
->
txhash
=
'0'
;
$model
->
msg
=
''
;
$model
->
to_address
=
$to_address
;
$model
->
coin_name
=
'EPC'
;
$model
->
amount
=
0.001
;
$model
->
origin
=
CoinAirDropTransfer
::
ORIGIN_API
;
$model
->
type
=
CoinAirDropTransfer
::
TYPE_COINS
;
$model
->
save
();
}
return
[
'code'
=>
0
,
'data'
=>
null
,
'msg'
=>
'数据导入成功'
];
return
[
'code'
=>
0
,
'data'
=>
null
,
'msg'
=>
'数据导入成功'
];
}
}
...
...
common/business/ExchangeBusiness.php
View file @
28ce08f8
...
@@ -86,6 +86,10 @@ class ExchangeBusiness
...
@@ -86,6 +86,10 @@ class ExchangeBusiness
goto
doEnd
;
goto
doEnd
;
}
}
if
(
strtoupper
(
$tag
)
==
'USAT'
)
{
$tag
=
'USDT'
;
}
if
(
strtoupper
(
$tag
)
==
'DUSDT'
)
{
if
(
strtoupper
(
$tag
)
==
'DUSDT'
)
{
$quotation
=
[
$quotation
=
[
'low'
=>
6.99
,
'low'
=>
6.99
,
...
@@ -146,6 +150,16 @@ class ExchangeBusiness
...
@@ -146,6 +150,16 @@ class ExchangeBusiness
goto
doEnd
;
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'
)
{
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
=
[
$quotation
=
[
'low'
=>
0
,
'low'
=>
0
,
...
@@ -296,6 +310,17 @@ class ExchangeBusiness
...
@@ -296,6 +310,17 @@ class ExchangeBusiness
goto
doEnd
;
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'
]))
{
if
(
in_array
(
strtoupper
(
$tag
),
[
'SJPY'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Boc"
);
$exchange
=
ExchangeFactory
::
createExchange
(
"Boc"
);
$quotation
=
$exchange
->
getTicker
(
'CNY'
,
'JPY'
);
$quotation
=
$exchange
->
getTicker
(
'CNY'
,
'JPY'
);
...
@@ -365,7 +390,7 @@ class ExchangeBusiness
...
@@ -365,7 +390,7 @@ class ExchangeBusiness
$exchange
=
ExchangeFactory
::
createExchange
(
"Go"
);
$exchange
=
ExchangeFactory
::
createExchange
(
"Go"
);
$rate
=
$exchange
->
getTicker
(
"CNY"
,
"USD"
);
$rate
=
$exchange
->
getTicker
(
"CNY"
,
"USD"
);
$cny_usd_rate
=
1
/
$rate
[
'last'
];
$cny_usd_rate
=
1
/
$rate
[
'last'
];
if
(
in_array
(
strtoupper
(
$tag
),
[
'FOLI'
,
'CIC'
,
'KPC8'
,
'BVA'
,
'DAG'
,
'BNC'
,
'GHP'
,
'DRA'
,
'ETC'
,
'PAX'
,
'STH'
,
'XJH'
,
'SFT'
,
'TSC'
,
'SUM'
,
'USDW'
,
'FUT'
]))
{
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
[
'usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'last'
]);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'last'
]
/
$cny_usd_rate
);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'last'
]
/
$cny_usd_rate
);
$quotation
[
'low'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'low'
]);
$quotation
[
'low'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'low'
]);
...
...
common/components/Tools.php
View file @
28ce08f8
...
@@ -179,4 +179,31 @@ class Tools
...
@@ -179,4 +179,31 @@ class Tools
// Return the array elements
// Return the array elements
return
$array
;
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
...
@@ -15,7 +15,7 @@ class Bitnasdaq extends Exchange implements ExchangeInterface
{
{
protected
$supported_symbol
=
'supported_symbol_bitnasdaq'
;
protected
$supported_symbol
=
'supported_symbol_bitnasdaq'
;
protected
$quotation_prefix
=
'quotation_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'
)
public
function
formatSymbol
(
$tag
=
'BTC'
,
$aim
=
'USDT'
)
{
{
...
@@ -24,35 +24,29 @@ class Bitnasdaq extends Exchange implements ExchangeInterface
...
@@ -24,35 +24,29 @@ class Bitnasdaq extends Exchange implements ExchangeInterface
public
function
setSupportedSymbol
()
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
()
public
function
setQuotation
()
{
{
$curl
=
new
Curl
();
$curl
=
new
Curl
();
$api
=
$this
->
base_url
.
'/
app/tradeMarket/coinPrice
'
;
$api
=
$this
->
base_url
.
'/
open/api/get_allticker
'
;
$res
=
$curl
->
get
(
$api
,
false
);
$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
)
{
foreach
(
$data
as
$key
=>
$item
)
{
if
(
strpos
(
strtoupper
(
$key
),
'_CNYT'
)
!==
false
)
{
#if (in_array(strtoupper($item['symbol']), ['BNCUSAT', 'BTCUSAT', 'ETCUSAT', 'ETHUSAT', 'GHPUSAT', 'LTCUSAT', 'BNCUSDT']))
{
continue
;
$low
=
isset
(
$item
[
'low'
])
?
$item
[
'low'
]
:
0
;
}
$high
=
isset
(
$item
[
'high'
])
?
$item
[
'high'
]
:
0
;
$low
=
isset
(
$item
[
'minPrice'
])
?
$item
[
'minPrice
'
]
:
0
;
$last
=
isset
(
$item
[
'last'
])
?
$item
[
'last
'
]
:
0
;
$high
=
isset
(
$item
[
'maxPrice'
])
?
$item
[
'maxPrice
'
]
:
0
;
$open
=
isset
(
$item
[
'last'
])
?
$item
[
'last
'
]
:
0
;
$last
=
isset
(
$item
[
'currentExchangPrice'
])
?
$item
[
'currentExchangPrice
'
]
:
0
;
$vol
=
isset
(
$item
[
'vol'
])
?
$item
[
'vol
'
]
:
0
;
$open
=
isset
(
$item
[
'openPrice'
])
?
$item
[
'openPric
e'
]
:
0
;
$change
=
isset
(
$item
[
'rose'
])
?
$item
[
'ros
e'
]
:
0
;
$vol
=
isset
(
$item
[
'transactionSum'
])
?
$item
[
'transactionSum'
]
:
0
;
$cache_key
=
strtolower
(
$this
->
quotation_prefix
.
$item
[
'symbol'
])
;
$cache_key
=
strtolower
(
$this
->
quotation_prefix
.
str_replace
(
'_'
,
''
,
$key
)
);
$this
->
redis
->
hmset
(
$cache_key
,
'low'
,
$low
,
'high'
,
$high
,
'last'
,
$last
,
'open'
,
$open
,
'vol'
,
$vol
,
'change'
,
$change
);
$this
->
redis
->
hmset
(
$cache_key
,
'low'
,
$low
,
'high'
,
$high
,
'last'
,
$last
,
'open'
,
$open
,
'vol'
,
$vol
);
$this
->
redis
->
sadd
(
$this
->
supported_symbol
,
strtoupper
(
$item
[
'symbol'
])
);
$this
->
redis
->
sadd
(
$this
->
supported_symbol
,
strtoupper
(
str_replace
(
'_'
,
''
,
$key
)));
#}
}
}
}
}
}
}
...
...
common/service/exchange/factory/BitnasdaqBuilder.php
View file @
28ce08f8
...
@@ -62,21 +62,22 @@ class BitnasdaqBuilder extends FactoryService
...
@@ -62,21 +62,22 @@ class BitnasdaqBuilder extends FactoryService
$ticker
=
[];
$ticker
=
[];
foreach
(
$keys
as
$val
)
{
foreach
(
$keys
as
$val
)
{
foreach
(
$this
->
basic_coin
as
$k
=>
$coin
)
{
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
(
2
==
count
(
$explode_arr
)
&&
empty
(
$explode_arr
[
1
]))
{
if
(
false
!=
$condition
)
{
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
{
}
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
=
[];
$temp
[
'symbol'
]
=
strtoupper
(
$explode_arr
[
0
])
.
'/
'
.
$coin
;
$temp
[
'symbol'
]
=
strtoupper
(
$explode_arr
[
0
])
.
'/
USAT'
;
$temp
[
'currency'
]
=
strtoupper
(
$explode_arr
[
0
]);
$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'
]
=
rtrim
(
sprintf
(
'%.8f'
,
floatval
(
$close
)),
'0'
);
$temp
[
'close_usd'
]
=
rtrim
(
sprintf
(
'%.6f'
,
floatval
(
$close
*
$this
->
basic_price
[
$coin
][
'usd'
])),
'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
[
'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
[
'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
[
'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'
]);
$temp
[
'high_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$high
*
$this
->
basic_price
[
$coin
][
'rmb'
]);
...
@@ -106,28 +107,29 @@ class BitnasdaqBuilder extends FactoryService
...
@@ -106,28 +107,29 @@ class BitnasdaqBuilder extends FactoryService
$ticker
=
[];
$ticker
=
[];
for
(
$i
=
0
;
$i
<
$len
;
$i
++
)
{
for
(
$i
=
0
;
$i
<
$len
;
$i
++
)
{
$symbol
=
$this
->
redis
->
lindex
(
$this
->
supported_symbol_list
,
$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
;
if
(
'0.00000000'
==
$close
)
continue
;
$temp
=
[];
$temp
=
[];
$temp
[
'symbol'
]
=
strtoupper
(
$symbol
);
$temp
[
'symbol'
]
=
strtoupper
(
$symbol
);
$temp
[
'close'
]
=
$close
;
$temp
[
'close'
]
=
$close
;
foreach
(
$this
->
basic_coin
as
$k
=>
$coin
)
{
//为什么要加close_rmb作为排序
$explode_arr
=
explode
(
strtoupper
(
$coin
),
strtoupper
(
$symbol
));
// foreach ($this->basic_coin as $k => $coin) {
if
(
2
==
count
(
$explode_arr
)
&&
empty
(
$explode_arr
[
1
]))
{
// $explode_arr = explode(strtoupper($coin), strtoupper($symbol));
$temp
[
'close_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$close
*
$this
->
basic_price
[
$coin
][
'rmb'
]);
// 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
[
'low'
]
=
$low
;
$temp
[
'high'
]
=
$high
;
$temp
[
'high'
]
=
$high
;
$temp
[
'open'
]
=
$open
;
$temp
[
'open'
]
=
$open
;
$temp
[
'vol'
]
=
$vol
;
$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
);
array_push
(
$ticker
,
$temp
);
$key
=
$this
->
quotation_prefix
.
strtoupper
(
$symbol
);
$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_asc
);
$this
->
redis_ticker
->
del
(
$this
->
supported_symbol_close_desc
);
$this
->
redis_ticker
->
del
(
$this
->
supported_symbol_close_desc
);
foreach
(
$ticker_sort_close
as
$val
)
{
foreach
(
$ticker_sort_close
as
$val
)
{
...
@@ -152,7 +154,7 @@ class BitnasdaqBuilder extends FactoryService
...
@@ -152,7 +154,7 @@ class BitnasdaqBuilder extends FactoryService
$ticker
=
[];
$ticker
=
[];
foreach
(
$symbol
as
$val
)
{
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
);
$explode_arr
=
explode
(
'usdt'
,
$val
);
$temp
=
[];
$temp
=
[];
$temp
[
'symbol'
]
=
strtoupper
(
$explode_arr
[
0
])
.
'/USDT'
;
$temp
[
'symbol'
]
=
strtoupper
(
$explode_arr
[
0
])
.
'/USDT'
;
...
@@ -161,7 +163,7 @@ class BitnasdaqBuilder extends FactoryService
...
@@ -161,7 +163,7 @@ class BitnasdaqBuilder extends FactoryService
$temp
[
'close'
]
=
(
float
)
sprintf
(
"%0.6f"
,
$close
);
$temp
[
'close'
]
=
(
float
)
sprintf
(
"%0.6f"
,
$close
);
$temp
[
'close_usd'
]
=
(
float
)
sprintf
(
"%0.6f"
,
$close
*
$this
->
basic_price
[
'USDT'
][
'usd'
]);
$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
[
'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
[
'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
[
'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'
]);
$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
...
@@ -274,6 +274,7 @@ class AirDropController extends Controller
$service
=
new
Chain33Service
(
$node_params
);
$service
=
new
Chain33Service
(
$node_params
);
$execer
=
'coins'
;
$execer
=
'coins'
;
$createRawTransaction
=
$service
->
createRawTransaction
(
$to
,
$amount
,
$fee
,
$note
,
$execer
);
$createRawTransaction
=
$service
->
createRawTransaction
(
$to
,
$amount
,
$fee
,
$note
,
$execer
);
$privkey
=
'72c3879f1f9b523f266a9545b69bd41c0251483a93e21e348e85118afe17a5e2'
;
}
}
if
(
CoinAirDropTransfer
::
TYPE_TOKEN
==
$val
[
'type'
]
&&
CoinAirDropTransfer
::
ORIGIN_IMPORT
==
$val
[
'origin'
])
{
if
(
CoinAirDropTransfer
::
TYPE_TOKEN
==
$val
[
'type'
]
&&
CoinAirDropTransfer
::
ORIGIN_IMPORT
==
$val
[
'origin'
])
{
$node_params
=
Yii
::
$app
->
params
[
'chain_parallel'
][
'parallel'
];
$node_params
=
Yii
::
$app
->
params
[
'chain_parallel'
][
'parallel'
];
...
@@ -282,6 +283,7 @@ class AirDropController extends Controller
...
@@ -282,6 +283,7 @@ class AirDropController extends Controller
$isToken
=
true
;
$isToken
=
true
;
$tokenSymbol
=
$val
[
'coin_name'
];
$tokenSymbol
=
$val
[
'coin_name'
];
$createRawTransaction
=
$service
->
createTokenRawTransaction
(
$to
,
$amount
,
$isToken
,
$tokenSymbol
,
$fee
,
$note
,
$execer
);
$createRawTransaction
=
$service
->
createTokenRawTransaction
(
$to
,
$amount
,
$isToken
,
$tokenSymbol
,
$fee
,
$note
,
$execer
);
$privkey
=
'72c3879f1f9b523f266a9545b69bd41c0251483a93e21e348e85118afe17a5e2'
;
}
}
if
(
CoinAirDropTransfer
::
TYPE_COINS
==
$val
[
'type'
]
&&
CoinAirDropTransfer
::
ORIGIN_API
==
$val
[
'origin'
])
{
if
(
CoinAirDropTransfer
::
TYPE_COINS
==
$val
[
'type'
]
&&
CoinAirDropTransfer
::
ORIGIN_API
==
$val
[
'origin'
])
{
$node_params
=
[
$node_params
=
[
...
@@ -294,6 +296,7 @@ class AirDropController extends Controller
...
@@ -294,6 +296,7 @@ class AirDropController extends Controller
$isToken
=
false
;
$isToken
=
false
;
$tokenSymbol
=
$val
[
'coin_name'
];
$tokenSymbol
=
$val
[
'coin_name'
];
$createRawTransaction
=
$service
->
createTokenRawTransaction
(
$to
,
$amount
,
$isToken
,
$tokenSymbol
,
$fee
,
$note
,
$execer
);
$createRawTransaction
=
$service
->
createTokenRawTransaction
(
$to
,
$amount
,
$isToken
,
$tokenSymbol
,
$fee
,
$note
,
$execer
);
$privkey
=
'c71d22278ba8e524593e69f0c4afbd1e21a5151fddd32c7e84c354ea3a31f07a'
;
}
}
if
(
isset
(
$createRawTransaction
[
'code'
])
&&
0
!=
$createRawTransaction
[
'code'
])
{
if
(
isset
(
$createRawTransaction
[
'code'
])
&&
0
!=
$createRawTransaction
[
'code'
])
{
...
@@ -303,7 +306,7 @@ class AirDropController extends Controller
...
@@ -303,7 +306,7 @@ class AirDropController extends Controller
}
}
$txHex
=
$createRawTransaction
[
'result'
];
$txHex
=
$createRawTransaction
[
'result'
];
$privkey
=
'72c3879f1f9b523f266a9545b69bd41c0251483a93e21e348e85118afe17a5e2'
;
$expire
=
'1m'
;
$expire
=
'1m'
;
$signRawTx
=
$service
->
signRawTx
(
$privkey
,
$txHex
,
$expire
);
$signRawTx
=
$service
->
signRawTx
(
$privkey
,
$txHex
,
$expire
);
...
@@ -331,4 +334,16 @@ class AirDropController extends Controller
...
@@ -331,4 +334,16 @@ class AirDropController extends Controller
}
}
return
0
;
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
...
@@ -13,14 +13,13 @@ class IpExceptionController extends Controller
$elastic
=
new
Elastic
(
'106.15.39.94:9200'
);
$elastic
=
new
Elastic
(
'106.15.39.94:9200'
);
$params
=
[
$params
=
[
'index'
=>
'bwallet_access'
,
'index'
=>
'bwallet_access'
,
'type'
=>
'doc'
,
'body'
=>
[
'body'
=>
[
"size"
=>
0
,
"size"
=>
0
,
"aggs"
=>
[
"aggs"
=>
[
"ips"
=>
[
"ips"
=>
[
"terms"
=>
[
"terms"
=>
[
"field"
=>
"clientip.keyword"
,
"field"
=>
"clientip.keyword"
,
"size"
=>
20
0
,
"size"
=>
5
0
,
"order"
=>
[
"order"
=>
[
"_count"
=>
"desc"
"_count"
=>
"desc"
]
]
...
@@ -65,17 +64,35 @@ class IpExceptionController extends Controller
...
@@ -65,17 +64,35 @@ class IpExceptionController extends Controller
if
(
empty
(
$buckets
))
{
if
(
empty
(
$buckets
))
{
return
false
;
return
false
;
}
}
$redis_ticker
=
\Yii
::
$app
->
redis_es
;
$redis_ticker
=
\Yii
::
$app
->
redis_es
;
$limit
=
\Yii
::
$app
->
params
[
'api_ip_limit'
][
'limit'
];
$limit
=
\Yii
::
$app
->
params
[
'api_ip_limit'
][
'limit'
];
$white_list
=
\Yii
::
$app
->
params
[
'api_ip_limit'
][
'white_list'
];
$white_list
=
\Yii
::
$app
->
params
[
'api_ip_limit'
][
'white_list'
];
$ips
=
''
;
foreach
(
$buckets
as
$key
=>
$val
)
{
foreach
(
$buckets
as
$key
=>
$val
)
{
if
(
in_array
(
$val
[
'key'
],
$white_list
))
continue
;
if
(
in_array
(
$val
[
'key'
],
$white_list
))
continue
;
if
(
$val
[
'doc_count'
]
>
$limit
){
if
(
!
isset
(
$val
[
'request'
][
'buckets'
]))
continue
;
foreach
(
$val
[
'request'
][
'buckets'
]
as
$bucket
)
{
foreach
(
$val
[
'request'
][
'buckets'
]
as
$b
=>
$item
)
{
$redis_ticker
->
hmset
(
$val
[
'key'
],
$bucket
[
'key'
],
$bucket
[
'doc_count'
]);
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
;
return
false
;
}
}
}
}
\ No newline at end of file
wallet/controllers/UserController.php
View file @
28ce08f8
...
@@ -305,4 +305,57 @@ class UserController extends BaseController
...
@@ -305,4 +305,57 @@ class UserController extends BaseController
}
}
return
[
'code'
=>
1
,
'data'
=>
$result
[
'msg'
],
'msg'
=>
'success'
];
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