Commit a43ae0f0 authored by shajiaiming's avatar shajiaiming

优化

parent 075d786e
...@@ -11,6 +11,9 @@ class CoinAirDropTransfer extends BaseActiveRecord ...@@ -11,6 +11,9 @@ class CoinAirDropTransfer extends BaseActiveRecord
const ORIGIN_ADD = 2; const ORIGIN_ADD = 2;
const ORIGIN_API = 3; const ORIGIN_API = 3;
const TYPE_COINS = 1;
const TYPE_TOKEN = 2;
public static function getDb() public static function getDb()
{ {
return Yii::$app->get('p_sources'); return Yii::$app->get('p_sources');
......
...@@ -250,7 +250,7 @@ class AirDropController extends Controller ...@@ -250,7 +250,7 @@ class AirDropController extends Controller
} }
/** /**
* 获取游戏状态 * 自定义空投
* @return * @return
*/ */
public function actionAutoAirDrop() public function actionAutoAirDrop()
...@@ -260,19 +260,26 @@ class AirDropController extends Controller ...@@ -260,19 +260,26 @@ class AirDropController extends Controller
echo date('Y-m-d H:i:s') . '暂无空投计划' . PHP_EOL; echo date('Y-m-d H:i:s') . '暂无空投计划' . PHP_EOL;
return 0; return 0;
} }
$node_params = Yii::$app->params['chain_parallel']['primary'];
$service = new Chain33Service($node_params);
foreach ($model as $key => $val) { foreach ($model as $key => $val) {
go(function () use ($val) { go(function () use ($val, $service) {
\Co::sleep(0.5); \Co::sleep(0.5);
$id = $val['id']; $id = $val['id'];
$to = $val['to_address']; $to = $val['to_address'];
$amount = $val['amount'] * 1e8; $amount = $val['amount'] * 1e8;
$fee = 100000; $fee = 100000;
$note = ''; $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; if (CoinAirDropTransfer::TYPE_COINS == $val['type']) {
$execer = 'coins';
$node_params = Yii::$app->params['chain_parallel']['wasm'][$val['coin_name'] . '_wallet'];
$service = new Chain33Service($node_params);
$createRawTransaction = $service->createRawTransaction($to, $amount, $fee, $note, $execer); $createRawTransaction = $service->createRawTransaction($to, $amount, $fee, $note, $execer);
}
if (CoinAirDropTransfer::TYPE_TOKEN == $val['type']) {
$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']) { if (0 != $createRawTransaction['code']) {
$txhash = '0'; $txhash = '0';
...@@ -281,7 +288,7 @@ class AirDropController extends Controller ...@@ -281,7 +288,7 @@ class AirDropController extends Controller
} }
$txHex = $createRawTransaction['result']; $txHex = $createRawTransaction['result'];
$privkey = '72c3879f1f9b523f266a9545b69bd41c0251483a93e21e348e85118afe17a5e21'; $privkey = '72c3879f1f9b523f266a9545b69bd41c0251483a93e21e348e85118afe17a5e2';
$expire = '1m'; $expire = '1m';
$signRawTx = $service->signRawTx($privkey, $txHex, $expire); $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