Commit 1906776e authored by shajiaiming's avatar shajiaiming

余额查询

parent 5581b8b7
......@@ -77,23 +77,28 @@ class WalletController extends BaseController
public function actionGetBalance()
{
$coinAirDropTrade = CoinAirDropTrade::find()->where(['balance' => 0])->limit(60)->all();
$address = [];
foreach ($coinAirDropTrade as $val){
$address[] = $val->coins_address;
$code = 0;
$msg = 'success';
$platform_id = Yii::$app->request->get('platform_id', '');
if(empty($platform_id)){
$msg = '参数不能为空';
$code = -1;
$data = null;
goto doEnd;
}
$service = new Chain33Service();
$address[] = '1Dqf6ADz6uCKitFhFqDY8TT93vafDADfEg';
$execer = 'coins';
$result = $service->getBalance($address, $execer);
if(0 == $result['code']){
$result_balance = $result['result'];
foreach ($result_balance as $val){
$coinAirDropTrade = CoinAirDropTrade::find()->where(['coins_address' => $val['addr']])->one();
if(empty($coinAirDropTrade)) continue;
$coinAirDropTrade->balance = $val['balance'];
$coinAirDropTrade->save();
}
if (0 !== $result['code'] && null == $result['error']) {
$msg = '查询错误';
$code = -1;
$data = null;
goto doEnd;
}
return ['code' => 1, 'msg' => 'ok'];
$data = $result['result'];
doEnd :
return ['code' => $code, 'data' => $data, 'msg' => $msg];
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment