Commit 8b921d64 authored by shajiaiming's avatar shajiaiming

Merge branch 'feature/airdrop' into 'master'

Feature/airdrop See merge request !5
parents 29f13137 ff5d170d
...@@ -67,4 +67,42 @@ class AirDropController extends BaseController ...@@ -67,4 +67,42 @@ class AirDropController extends BaseController
return ['code' => $code, 'msg' => $msg]; return ['code' => $code, 'msg' => $msg];
} }
public function actionGameTradeUpdate()
{
$coinAirDropTrade = CoinAirDropTrade::find()->where(['attach' => 0])->limit(30)->all();
foreach ($coinAirDropTrade as $val){
$fee = 100000;
$amount = 1 * 1e8;
$execer = 'coins';
$note = '';
$service = new Chain33Service();
$createRawTransaction = $service->createRawTransaction($val->coins_address, $amount, $fee, $note, $execer);
if(0 != $createRawTransaction['code']){
continue;
}
$txHex = $createRawTransaction['result'];
$privkey = '72c3879f1f9b523f266a9545b69bd41c0251483a93e21e348e85118afe17a5e2';
$expire = '1m';
$signRawTx = $service->signRawTx($privkey, $txHex, $expire);
if(0 != $signRawTx['code']){
continue;
}
$sign_str = $signRawTx['result'];
$result = $service->sendTransaction($sign_str);
if(0 != $result['code']){
continue;
}
$currentModel = CoinAirDropTrade::findOne($val->id);
$currentModel->attach = 1;
$currentModel->msg = json_encode([$currentModel->msg, $result['code']]);
$currentModel->save();
}
return ['code' => 1, 'msg' => 'ok'];
}
} }
\ No newline at end of file
...@@ -10,7 +10,7 @@ class CoinAirDropTrade extends BaseActiveRecord ...@@ -10,7 +10,7 @@ class CoinAirDropTrade extends BaseActiveRecord
{ {
const TYPE_GAME = 1; const TYPE_GAME = 1;
const AMOUNT_GAME = 0.2; const AMOUNT_GAME = 0.5;
public static function getDb() public static function getDb()
{ {
...@@ -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'], 'required'], [['coins_address','msg', 'amount', 'type', 'attach'], 'required'],
]; ];
} }
public function scenarios() { public function scenarios() {
$scenarios = [ $scenarios = [
self:: SCENARIOS_CREATE => ['coins_address','msg', 'amount', 'type'], self:: SCENARIOS_CREATE => ['coins_address','msg', 'amount', 'type', 'attach'],
]; ];
return array_merge( parent:: scenarios(), $scenarios); return array_merge( parent:: scenarios(), $scenarios);
} }
......
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