Commit 1b1afc7b authored by shajiaiming's avatar shajiaiming

Merge branch 'feature/airdrop' into 'master'

空投规则 See merge request !326
parents a2e2f89e 06d400ff
......@@ -207,6 +207,49 @@ class AirDropController extends BaseController
return ['code' => $this->code, 'msg' => $this->msg, 'data' => $this->data];
}
public function actionRule()
{
$data = Yii::$app->request->get();
$identifier = $data['identifier'] ?? null;
$miner_address = $data['miner_address'] ?? null;
if (false == $identifier || false == $miner_address) {
$this->code = -1;
$this->msg = 'Validation failed.';
goto doEnd;
}
$exist = AirDropRulePool::find()->where(['identifier' => $identifier])->one();
if (false == $exist || false == $exist->rule) {
$this->code = -1;
$this->msg = 'Validation failed.';
goto doEnd;
}
$token = $exist->rule->token;
$amount = $exist->rule->amount;
$apply = AirDrop::find()->select('id')->where(['identifier' => $identifier, 'miner_address' => $miner_address])->asArray()->one();
if (empty($apply)) {
$this->code = -1;
$this->msg = 'Validation failed.';
goto doEnd;
}
$record = AirDropApplyRecord::find()->select('create_time')->where(['apply_id' => $apply['id']])->orderBy('id')->asArray()->all();
if (empty($record)) {
$begin_time = '?';
$over_time = '?';
} else {
$create_time_arr = array_column($record, 'create_time');
$begin_time = current($create_time_arr);
$over_time = end($create_time_arr);
}
$this->data = [
'token' => $token,
'amount' => $amount,
'begin_time' => $begin_time,
'over_time' => $over_time
];
doEnd :
return ['code' => $this->code, 'msg' => $this->msg, 'data' => $this->data];
}
public function actionGameTrade()
{
$coins_address = Yii::$app->request->post('coins_address', '');
......
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