Commit 7a73e2c8 authored by shajiaiming's avatar shajiaiming

Merge branch 'feature/airdrop' into 'master'

Feature/airdrop See merge request !346
parents b87f07cd 896cfbfe
......@@ -11,6 +11,9 @@ class CoinAirDropTransfer extends BaseActiveRecord
const ORIGIN_ADD = 2;
const ORIGIN_API = 3;
const TYPE_COINS = 1;
const TYPE_TOKEN = 2;
public static function getDb()
{
return Yii::$app->get('p_sources');
......
......@@ -250,7 +250,7 @@ class AirDropController extends Controller
}
/**
* 获取游戏状态
* 自定义空投
* @return
*/
public function actionAutoAirDrop()
......@@ -260,6 +260,7 @@ class AirDropController extends Controller
echo date('Y-m-d H:i:s') . '暂无空投计划' . PHP_EOL;
return 0;
}
foreach ($model as $key => $val) {
go(function () use ($val) {
\Co::sleep(0.5);
......@@ -268,11 +269,20 @@ class AirDropController extends Controller
$amount = $val['amount'] * 1e8;
$fee = 100000;
$note = '';
$execer = isset(Yii::$app->params['chain_parallel']['wasm'][$val['coin_name'] . '_wallet']) ? Yii::$app->params['chain_parallel']['wasm'][$val['coin_name'] . '_wallet']['execer'] : null;
$node_params = Yii::$app->params['chain_parallel']['wasm'][$val['coin_name'] . '_wallet'];
if (CoinAirDropTransfer::TYPE_COINS == $val['type']) {
$node_params = Yii::$app->params['chain_parallel']['primary'];
$service = new Chain33Service($node_params);
$execer = 'coins';
$createRawTransaction = $service->createRawTransaction($to, $amount, $fee, $note, $execer);
}
if (CoinAirDropTransfer::TYPE_TOKEN == $val['type']) {
$node_params = Yii::$app->params['chain_parallel']['parallel'];
$service = new Chain33Service($node_params);
$execer = 'user.p.mall.token';
$isToken = true;
$tokenSymbol = $val['coin_name'];
$createRawTransaction = $service->createTokenRawTransaction($to, $amount, $isToken, $tokenSymbol, $fee, $note, $execer);
}
if (0 != $createRawTransaction['code']) {
$txhash = '0';
......@@ -281,7 +291,7 @@ class AirDropController extends Controller
}
$txHex = $createRawTransaction['result'];
$privkey = '72c3879f1f9b523f266a9545b69bd41c0251483a93e21e348e85118afe17a5e21';
$privkey = '72c3879f1f9b523f266a9545b69bd41c0251483a93e21e348e85118afe17a5e2';
$expire = '1m';
$signRawTx = $service->signRawTx($privkey, $txHex, $expire);
......
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