Commit da76d9eb authored by shajiaiming's avatar shajiaiming

fix

parent 64ae6e97
......@@ -62,37 +62,43 @@ class AirDropController extends BaseController
];
}
if (Yii::$app->request->isPut) {
$data = Yii::$app->request->post();
$id = $data['id'] ?? '';
$identifier = $data['identifier'] ?? '';
$miner_address = $data['miner_address'] ?? '';
if (false == $id || false == $identifier || false == $miner_address) {
$this->code = -1;
$this->msg = 'Validation failed.';
goto doEnd;
}
$model = AirDrop::find()->select('id')->where(['identifier' => $identifier, 'miner_address' => $miner_address])->one();
doEnd :
return ['code' => $this->code, 'msg' => $this->msg, 'data' => $this->data];
}
if (empty($model) || empty($model->record)) {
$this->code = -1;
$this->msg = '暂无符合条件的空投申请记录';
goto doEnd;
}
public function actionBatchDraw()
{
if (!Yii::$app->request->isPost) {
$this->code = -1;
$this->msg = '请求方式错误!';
goto doEnd;
}
$record = AirDropApplyRecord::find()->where(['id' => $id, 'reach' => AirDropApplyRecord::REACH_YES, 'draw_status' => AirDropApplyRecord::STATUS_UNDRAW])->one();
if (empty($record)) {
$this->code = -1;
$this->msg = '暂无符合条件的领取记录';
goto doEnd;
}
$data = Yii::$app->request->post();
$identifier = $data['identifier'] ?? '';
$miner_address = $data['miner_address'] ?? '';
if (false == $identifier || false == $miner_address) {
$this->code = -1;
$this->msg = 'Validation failed.';
goto doEnd;
}
$model = AirDrop::find()->select('id')->where(['identifier' => $identifier, 'miner_address' => $miner_address])->one();
$record->draw_status = AirDropApplyRecord::STATUS_DRAWING;
if (false == $record->save()) {
$this->code = -1;
$this->msg = $record->errors;
goto doEnd;
}
if (empty($model) || empty($model->record)) {
$this->code = -1;
$this->msg = '暂无符合条件的空投申请记录';
goto doEnd;
}
$record = AirDropApplyRecord::find()->where(['apply_id' => $model['id'], 'reach' => AirDropApplyRecord::REACH_YES, 'draw_status' => AirDropApplyRecord::STATUS_UNDRAW])->all();
if (empty($record)) {
$this->code = -1;
$this->msg = '暂无符合条件的领取记录';
goto doEnd;
}
foreach ($record as $val) {
$val->draw_status = AirDropApplyRecord::STATUS_DRAWING;
$val->save();
}
doEnd :
......@@ -101,33 +107,41 @@ class AirDropController extends BaseController
public function actionDraw()
{
if (Yii::$app->request->isPost) {
$data = Yii::$app->request->post();
$identifier = $data['identifier'] ?? '';
$miner_address = $data['miner_address'] ?? '';
if (false == $identifier || false == $miner_address) {
$this->code = -1;
$this->msg = 'Validation failed.';
goto doEnd;
}
$model = AirDrop::find()->select('id')->where(['identifier' => $identifier, 'miner_address' => $miner_address])->one();
if (!Yii::$app->request->isPost) {
$this->code = -1;
$this->msg = '请求方式错误!';
goto doEnd;
}
if (empty($model) || empty($model->record)) {
$this->code = -1;
$this->msg = '暂无符合条件的空投申请记录';
goto doEnd;
}
$data = Yii::$app->request->post();
$id = $data['id'] ?? '';
$identifier = $data['identifier'] ?? '';
$miner_address = $data['miner_address'] ?? '';
if (false == $id || false == $identifier || false == $miner_address) {
$this->code = -1;
$this->msg = 'Validation failed.';
goto doEnd;
}
$model = AirDrop::find()->select('id')->where(['identifier' => $identifier, 'miner_address' => $miner_address])->one();
$record = AirDropApplyRecord::find()->where(['apply_id' => $model['id'], 'reach' => AirDropApplyRecord::REACH_YES, 'draw_status' => AirDropApplyRecord::STATUS_UNDRAW])->all();
if (empty($record)) {
$this->code = -1;
$this->msg = '暂无符合条件的领取记录';
goto doEnd;
}
foreach ($record as $val) {
$val->draw_status = AirDropApplyRecord::STATUS_DRAWING;
$val->save();
}
if (empty($model) || empty($model->record)) {
$this->code = -1;
$this->msg = '暂无符合条件的空投申请记录';
goto doEnd;
}
$record = AirDropApplyRecord::find()->where(['id' => $id, 'reach' => AirDropApplyRecord::REACH_YES, 'draw_status' => AirDropApplyRecord::STATUS_UNDRAW])->one();
if (empty($record)) {
$this->code = -1;
$this->msg = '暂无符合条件的领取记录';
goto doEnd;
}
$record->draw_status = AirDropApplyRecord::STATUS_DRAWING;
if (false == $record->save()) {
$this->code = -1;
$this->msg = $record->errors;
goto doEnd;
}
doEnd :
......
......@@ -28,6 +28,8 @@ class AirDrop extends CommonActiveRecord
[['reach_times'], 'integer'],
[['identifier'], 'string', 'length' => [5, 50]],
[['wallet_address', 'miner_address'], 'string', 'length' => [10, 50]],
['identifier', 'unique', 'message' => '树莓派编号已存在'],
['miner_address', 'unique', 'message' => '矿工地址已存在'],
];
}
......
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