Commit 0a94b8e7 authored by shajiaiming's avatar shajiaiming

处理退回矿机空投数据

parent d0aa41b8
<?php
namespace common\models\psources;
use Yii;
use yii\db\Expression;
class AirDropRefund extends CommonActiveRecord
{
//定义场景
const SCENARIOS_CREATE = 'create';
const SCENARIOS_UPDATE = 'update';
public static function getDb()
{
return Yii::$app->get('p_sources');
}
public static function tableName()
{
return '{{%wallet_airdrop_refund}}';
}
}
\ No newline at end of file
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
namespace wallet\controllers; namespace wallet\controllers;
use common\models\psources\AirDropApplyRecord; use common\models\psources\AirDropApplyRecord;
use common\models\psources\AirDropRefund;
use common\models\psources\AirDropRulePool;
use common\service\chain33\Chain33Service; use common\service\chain33\Chain33Service;
use Yii; use Yii;
use wallet\base\BaseController; use wallet\base\BaseController;
...@@ -145,4 +147,53 @@ class AirDropController extends BaseController ...@@ -145,4 +147,53 @@ class AirDropController extends BaseController
return ['code' => $this->code, 'msg' => $this->msg, 'data' => $this->data]; return ['code' => $this->code, 'msg' => $this->msg, 'data' => $this->data];
} }
public function actionStop()
{
$redis = Yii::$app->redis_app;
$redis->del('airdrop:1000000000000000');
exit;
var_dump($redis->hget('airdrop', 1000000000000000));
exit;
var_dump($redis->hdel('airdrop:', 1000000000000000));
exit;
if (!Yii::$app->request->isPost) {
$this->code = -1;
$this->msg = '错误的请求方式.';
goto doEnd;
}
$data = Yii::$app->request->post();
$identifier = $data['identifier'] ?? null;
if (empty($identifier)) {
goto doEnd;
}
$identifier = array_unique($identifier);
$model = AirDrop::find()->select('id,identifier,wallet_address,miner_address')->where(['in', 'identifier', $identifier])->asArray()->all();
if (empty($model)) {
goto doEnd;
}
$redis = Yii::$app->redis_app;
$refund = new AirDropRefund();
foreach ($model as $val) {
$sum = AirDropApplyRecord::find()->where(['apply_id' => $val['id']])
->andWhere(['reach' => AirDropApplyRecord::REACH_YES])
->andWhere(['draw_status' => AirDropApplyRecord::STATUS_DRAW_SUEEESS])
->sum('amount');
$refund->setIsNewRecord(true);
$refund->identifier = $val['identifier'];
$refund->wallet_address = $val['wallet_address'];
$refund->miner_address = $val['miner_address'];
$refund->draw_amount = $sum;
$refund->save() && $refund->id = 0;
AirDropRulePool::deleteAll('identifier = :identifier', [':identifier' => $val['identifier']]);
AirDropApplyRecord::deleteAll('apply_id = :apply_id', [':apply_id' => $val['id']]);
AirDrop::findOne($val['id'])->delete();
$redis->del($val['identifier']);
$redis->del('airdrop:' . $val['identifier']);
}
doEnd :
return ['code' => $this->code, 'msg' => $this->msg, 'data' => $this->data];
}
} }
\ No newline at end of file
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