Commit 5d0a1df3 authored by shajiaiming's avatar shajiaiming

领取情况

parent f32fa687
......@@ -66,8 +66,6 @@ class AirDropController extends BaseController
goto doEnd;
}
$model = AirDrop::find()->select('id')->where(['identifier' => $identifier, 'miner_address' => $miner_address])->one();
$total = 0;
$items = [];
if (empty($model) || empty($model->record)) {
goto doEnd;
}
......@@ -125,6 +123,42 @@ class AirDropController extends BaseController
return ['code' => $this->code, 'msg' => $this->msg, 'data' => (int)$this->data];
}
/**
* 空投领取情况
* @param identifier 树莓派编号
* @param miner_address 矿工地址
* @return array
*/
public function actionInfo()
{
if (Yii::$app->request->isPost) {
$this->code = -1;
$this->msg = '请求方式错误!';
goto doEnd;
}
$data = Yii::$app->request->get();
$identifier = $data['identifier'] ?? null;
if (false == $identifier) {
$this->code = -1;
$this->msg = 'Validation failed.';
goto doEnd;
}
$redis = Yii::$app->redis_app;
list($reach, $reached_times, $draw_success, $income, $un_draw) = $redis->hmget('airdrop:' . $identifier, 'reach', 'reached_times', 'draw_success', 'income', 'un_draw');
$this->data = [
'reach' => empty($reach) ? 0 : (int)$reach,
'reached_times' => empty($reached_times) ? 0 : (int)$reached_times,
'draw_success' => empty($draw_success) ? 0 : (int)$draw_success,
'income' => empty($income) ? 0 : (int)$reach,
'un_draw' => empty($un_draw) ? 0 : (int)$un_draw,
];
doEnd :
return ['code' => $this->code, 'msg' => $this->msg, 'data' => $this->data];
}
public function actionBatchDraw()
{
$this->code = -1;
......
......@@ -32,6 +32,7 @@ class AirDropController extends Controller
go(function () use ($val, $redis, $expiry_date) {
\Co::sleep(0.5);
if (!empty($val->record)) {
//达标次数
$reach = AirDropApplyRecord::find()
->where(['apply_id' => $val['id'], 'reach' => AirDropApplyRecord::REACH_YES])
......@@ -39,7 +40,14 @@ class AirDropController extends Controller
->sum('reach');
$reach = empty($reach) ? 0 : (int)$reach;
//已领取
//已领取次数
$reached_times = AirDropApplyRecord::find()
->where(['apply_id' => $val['id'], 'draw_status' => AirDropApplyRecord::STATUS_DRAW_SUEEESS])
->andWhere(['<', 'create_time', $expiry_date])
->count();
$reached_times = empty($reached_times) ? 0 : (int)$reached_times;
//已领取空投总量
$draw_success = AirDropApplyRecord::find()
->where(['apply_id' => $val['id'], 'draw_status' => AirDropApplyRecord::STATUS_DRAW_SUEEESS])
->andWhere(['<', 'create_time', $expiry_date])
......@@ -56,7 +64,7 @@ class AirDropController extends Controller
//未领取
$un_draw = $income - $draw_success;
$redis->hmset('airdrop:' . $val->identifier, 'reach', $reach, 'draw_success', $draw_success, 'income', $income, 'un_draw', $un_draw);
$redis->hmset('airdrop:' . $val->identifier, 'reach', $reach, 'reached_times', $reached_times, 'draw_success', $draw_success, 'income', $income, 'un_draw', $un_draw);
}
});
}
......
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