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,8 +61,8 @@ class FreezeJob extends BaseObject implements JobInterface ...@@ -59,8 +61,8 @@ 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) {
try{
$trans = CoinPublish::getDb()->beginTransaction(); $trans = CoinPublish::getDb()->beginTransaction();
$models = CoinReleaseMember::findOne($value['id']); $models = CoinReleaseMember::findOne($value['id']);
$models->release = $value['release']; $models->release = $value['release'];
...@@ -74,11 +76,16 @@ class FreezeJob extends BaseObject implements JobInterface ...@@ -74,11 +76,16 @@ class FreezeJob extends BaseObject implements JobInterface
$list->status = 1; $list->status = 1;
$list->from = $address; $list->from = $address;
$list->mid = $value['id']; $list->mid = $value['id'];
if ($models->save() && $list->save()) { if ($models->save(false) && $list->save(false)) {
$trans->commit(); $trans->commit();
} }
echo date('Y-m-d H:i:s').': 释放币成功 [Coin_release_member_id]: ' . $value['id'].PHP_EOL;
}catch (\Exception $e){
$trans->rollBack(); $trans->rollBack();
Yii::info('释放币失败, [Coin_release_member_id]: ' . $value['id'], __CLASS__); Yii::info('释放币失败, [Coin_release_member_id]: ' . $value['id'], __CLASS__);
echo date('Y-m-d H:i:s').': 释放币失败:'.$e->getMessage().PHP_EOL;
}
} }
// 执行下一次任务 // 执行下一次任务
......
...@@ -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