Commit 9c88496b authored by ZhuChunYang's avatar ZhuChunYang

修改解冻BUG

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