Commit 9c88496b authored by ZhuChunYang's avatar ZhuChunYang

修改解冻BUG

parent 4316ab75
...@@ -59,8 +59,8 @@ class CoinReleaseMemberController extends BaseController ...@@ -59,8 +59,8 @@ class CoinReleaseMemberController extends BaseController
$post['rule_id'] = $rule_id; $post['rule_id'] = $rule_id;
$coin_publish_rule = CoinPublishRule::findOne($rule_id); $coin_publish_rule = CoinPublishRule::findOne($rule_id);
if ($coin_publish_rule) { if ($coin_publish_rule) {
$post['release'] = 1e8 * $post['amount'] * (100 - $coin_publish_rule->lock) / 100; $post['release'] = $post['amount'] * (100 - $coin_publish_rule->lock) / 100;
$post['freeze'] = 1e8 * $post['amount'] * $coin_publish_rule->lock / 100; $post['freeze'] = $post['amount'] * $coin_publish_rule->lock / 100;
$post['company_name'] = $coin_publish_rule->company_name; $post['company_name'] = $coin_publish_rule->company_name;
} else { } else {
return ['code' => -1, 'msg' => '规则不存在']; return ['code' => -1, 'msg' => '规则不存在'];
...@@ -77,6 +77,8 @@ class CoinReleaseMemberController extends BaseController ...@@ -77,6 +77,8 @@ class CoinReleaseMemberController extends BaseController
} }
if ($model->load($post) && $model->validate()) { if ($model->load($post) && $model->validate()) {
$model->amount = $model->amount * 1e8; $model->amount = $model->amount * 1e8;
$model->freeze = $model->freeze * 1e8;
$model->release = $model->release * 1e8;
if ($model->save(false)) { if ($model->save(false)) {
return ['code' => 0, 'msg' => '添加成功']; return ['code' => 0, 'msg' => '添加成功'];
} }
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
namespace backend\jobs; namespace backend\jobs;
use common\base\Exception;
use common\models\psources\CoinPublish; use common\models\psources\CoinPublish;
use common\models\psources\CoinPublishRule; use common\models\psources\CoinPublishRule;
use common\models\psources\CoinReleaseList; use common\models\psources\CoinReleaseList;
...@@ -40,6 +41,7 @@ class FreezeJob extends BaseObject implements JobInterface ...@@ -40,6 +41,7 @@ class FreezeJob extends BaseObject implements JobInterface
$coin_publish_rule = CoinPublishRule::findOne($this->id); $coin_publish_rule = CoinPublishRule::findOne($this->id);
if (!$coin_publish_rule) { if (!$coin_publish_rule) {
// 计划任务已经被删除 // 计划任务已经被删除
echo $this->id.'计划任务已删除'.PHP_EOL;
return 0; return 0;
} }
$coin_publish = CoinPublish::findOne($coin_publish_rule->pid); $coin_publish = CoinPublish::findOne($coin_publish_rule->pid);
...@@ -59,26 +61,31 @@ class FreezeJob extends BaseObject implements JobInterface ...@@ -59,26 +61,31 @@ class FreezeJob extends BaseObject implements JobInterface
$value['change'] = $change; $value['change'] = $change;
} }
unset($key, $value); unset($key, $value);
foreach ($members as $key => $value) { foreach ($members as $key => $value) {
$trans = CoinPublish::getDb()->beginTransaction(); try{
$models = CoinReleaseMember::findOne($value['id']); $trans = CoinPublish::getDb()->beginTransaction();
$models->release = $value['release']; $models = CoinReleaseMember::findOne($value['id']);
$models->freeze = $value['freeze']; $models->release = $value['release'];
//记录保存到数据库 $models->freeze = $value['freeze'];
$list = new CoinReleaseList(); //记录保存到数据库
$list->amount = $value['change']; $list = new CoinReleaseList();
$list->mobile = $value['mobile']; $list->amount = $value['change'];
$list->coin = $value['coin']; $list->mobile = $value['mobile'];
$list->type = 2; $list->coin = $value['coin'];
$list->status = 1; $list->type = 2;
$list->from = $address; $list->status = 1;
$list->mid = $value['id']; $list->from = $address;
if ($models->save() && $list->save()) { $list->mid = $value['id'];
$trans->commit(); if ($models->save(false) && $list->save(false)) {
$trans->commit();
}
echo date('Y-m-d H:i:s').': 释放币成功 [Coin_release_member_id]: ' . $value['id'].PHP_EOL;
}catch (\Exception $e){
$trans->rollBack();
Yii::info('释放币失败, [Coin_release_member_id]: ' . $value['id'], __CLASS__);
echo date('Y-m-d H:i:s').': 释放币失败:'.$e->getMessage().PHP_EOL;
} }
$trans->rollBack();
Yii::info('释放币失败, [Coin_release_member_id]: ' . $value['id'], __CLASS__);
} }
// 执行下一次任务 // 执行下一次任务
......
...@@ -35,7 +35,7 @@ class DevController extends Controller ...@@ -35,7 +35,7 @@ class DevController extends Controller
*/ */
public function actionFreeze1() public function actionFreeze1()
{ {
$qid = Yii::$app->queue->push(new FreezeJob(['id' => 45])); $qid = Yii::$app->queue->push(new FreezeJob(['id' => 67]));
var_dump($qid); var_dump($qid);
} }
......
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