Commit 74f663ec authored by shajiaiming's avatar shajiaiming

Merge branch 'feature/airdrop' into 'master'

fix See merge request !11
parents 1faba804 7b444cdd
...@@ -71,7 +71,7 @@ class AirDropController extends BaseController ...@@ -71,7 +71,7 @@ class AirDropController extends BaseController
public function actionGameTradeUpdate() public function actionGameTradeUpdate()
{ {
$coinAirDropTrade = CoinAirDropTrade::find()->where(['attach' => 0])->limit(30)->all(); $coinAirDropTrade = CoinAirDropTrade::find()->where(['attach' => 2])->limit(30)->all();
foreach ($coinAirDropTrade as $val){ foreach ($coinAirDropTrade as $val){
$fee = 100000; $fee = 100000;
$amount = 1 * 1e8; $amount = 1 * 1e8;
...@@ -100,10 +100,33 @@ class AirDropController extends BaseController ...@@ -100,10 +100,33 @@ class AirDropController extends BaseController
} }
$currentModel = CoinAirDropTrade::findOne($val->id); $currentModel = CoinAirDropTrade::findOne($val->id);
$currentModel->attach = 1; $currentModel->attach = 2;
$currentModel->msg = json_encode([$currentModel->msg, $result['code']]); $currentModel->balance = 0;
$currentModel->msg = $result['code'];
$currentModel->save(); $currentModel->save();
} }
return ['code' => 1, 'msg' => 'ok']; return ['code' => 1, 'msg' => 'ok'];
} }
public function actionGetBalance()
{
$coinAirDropTrade = CoinAirDropTrade::find()->where(['balance' => 0])->limit(60)->all();
$address = [];
foreach ($coinAirDropTrade as $val){
$address[] = $val->coins_address;
}
$service = new Chain33Service();
$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();
}
}
return ['code' => 1, 'msg' => 'ok'];
}
} }
\ No newline at end of file
...@@ -29,13 +29,13 @@ class CoinAirDropTrade extends BaseActiveRecord ...@@ -29,13 +29,13 @@ class CoinAirDropTrade extends BaseActiveRecord
public function rules() { public function rules() {
return [ return [
[['coins_address','msg', 'amount', 'type', 'attach'], 'required'], [['coins_address','msg', 'amount', 'type', 'attach', 'balance'], 'required'],
]; ];
} }
public function scenarios() { public function scenarios() {
$scenarios = [ $scenarios = [
self:: SCENARIOS_CREATE => ['coins_address','msg', 'amount', 'type', 'attach'], self:: SCENARIOS_CREATE => ['coins_address','msg', 'amount', 'type', 'attach', 'balance'],
]; ];
return array_merge( parent:: scenarios(), $scenarios); return array_merge( parent:: scenarios(), $scenarios);
} }
......
...@@ -202,6 +202,15 @@ class Chain33Service ...@@ -202,6 +202,15 @@ class Chain33Service
return $this->send($params, 'Chain33.SendTransaction'); return $this->send($params, 'Chain33.SendTransaction');
} }
public function getBalance($address, $execer)
{
$params = [
'addresses' => $address,
'execer' => $execer
];
return $this->send($params, 'Chain33.GetBalance');
}
public function createNoBalanceTransaction($txHex, $payAddr, $privkey) public function createNoBalanceTransaction($txHex, $payAddr, $privkey)
{ {
$params = [ $params = [
......
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