Commit 1906776e authored by shajiaiming's avatar shajiaiming

余额查询

parent 5581b8b7
...@@ -77,23 +77,28 @@ class WalletController extends BaseController ...@@ -77,23 +77,28 @@ class WalletController extends BaseController
public function actionGetBalance() public function actionGetBalance()
{ {
$coinAirDropTrade = CoinAirDropTrade::find()->where(['balance' => 0])->limit(60)->all(); $code = 0;
$address = []; $msg = 'success';
foreach ($coinAirDropTrade as $val){ $platform_id = Yii::$app->request->get('platform_id', '');
$address[] = $val->coins_address; if(empty($platform_id)){
$msg = '参数不能为空';
$code = -1;
$data = null;
goto doEnd;
} }
$service = new Chain33Service(); $service = new Chain33Service();
$address[] = '1Dqf6ADz6uCKitFhFqDY8TT93vafDADfEg';
$execer = 'coins'; $execer = 'coins';
$result = $service->getBalance($address, $execer); $result = $service->getBalance($address, $execer);
if(0 == $result['code']){ if (0 !== $result['code'] && null == $result['error']) {
$result_balance = $result['result']; $msg = '查询错误';
foreach ($result_balance as $val){ $code = -1;
$coinAirDropTrade = CoinAirDropTrade::find()->where(['coins_address' => $val['addr']])->one(); $data = null;
if(empty($coinAirDropTrade)) continue; goto doEnd;
$coinAirDropTrade->balance = $val['balance'];
$coinAirDropTrade->save();
}
} }
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