Commit 010b4916 authored by rlgy's avatar rlgy

update

parent f3ab64e3
...@@ -21,8 +21,8 @@ class CoinReleaseMemberController extends BaseController ...@@ -21,8 +21,8 @@ class CoinReleaseMemberController extends BaseController
public function actionList() public function actionList()
{ {
$get = Yii::$app->request->get(); $get = Yii::$app->request->get();
$page = $get['page'] ?? 1; $page = $get['page'] ?? 1;
$limit = $get['limit'] ?? 10; $limit = $get['limit'] ?? 10;
if (Yii::$app->request->isAjax) { if (Yii::$app->request->isAjax) {
...@@ -33,7 +33,7 @@ class CoinReleaseMemberController extends BaseController ...@@ -33,7 +33,7 @@ class CoinReleaseMemberController extends BaseController
return ['code' => -1, 'msg' => 'failed']; return ['code' => -1, 'msg' => 'failed'];
} }
$condition = [['rule_id' => $rule_id]]; $condition = [['rule_id' => $rule_id]];
$datas = CoinReleaseMember::getList($page, $limit, $condition); $datas = CoinReleaseMember::getList($page, $limit, $condition);
return $datas; return $datas;
} }
return $this->render('list'); return $this->render('list');
...@@ -47,15 +47,15 @@ class CoinReleaseMemberController extends BaseController ...@@ -47,15 +47,15 @@ class CoinReleaseMemberController extends BaseController
} else { } else {
if (Yii::$app->request->isPost) { if (Yii::$app->request->isPost) {
Yii::$app->response->format = 'json'; Yii::$app->response->format = 'json';
$post = Yii::$app->request->post(); $post = Yii::$app->request->post();
// 获取rule_id // 获取rule_id
$rule_id = $this->getRuleId(); $rule_id = $this->getRuleId();
if ($rule_id) { if ($rule_id) {
$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'] = $post['amount'] * (100 - $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['freeze'] = $post['amount'] * $coin_publish_rule->lock / 100;
} else { } else {
return ['code' => -1, 'msg' => '规则不存在']; return ['code' => -1, 'msg' => '规则不存在'];
} }
...@@ -63,13 +63,16 @@ class CoinReleaseMemberController extends BaseController ...@@ -63,13 +63,16 @@ class CoinReleaseMemberController extends BaseController
return ['code' => -1, 'msg' => '规则不存在']; return ['code' => -1, 'msg' => '规则不存在'];
} }
if (isset($post['id']) && !empty($post['id'])) { if (isset($post['id']) && !empty($post['id'])) {
$model = CoinReleaseMember::findOne($post['id']); $model = CoinReleaseMember::findOne($post['id']);
$model->scenario = CoinReleaseMember::SCENARIOS_UPDATE; $model->scenario = CoinReleaseMember::SCENARIOS_UPDATE;
} else { } else {
$model = new CoinReleaseMember(); $model = new CoinReleaseMember();
$model->scenario = CoinReleaseMember::SCENARIOS_ADD; $model->scenario = CoinReleaseMember::SCENARIOS_ADD;
} }
if ($model->load($post) && $model->validate()) { if ($model->load($post) && $model->validate()) {
$model->amount = $model->amount * 1e8;
$model->release = $model->release * 1e8;
$model->freeze = $model->freeze * 1e8;
if ($model->save()) { if ($model->save()) {
return ['code' => 0, 'msg' => '添加成功']; return ['code' => 0, 'msg' => '添加成功'];
} }
...@@ -87,14 +90,14 @@ class CoinReleaseMemberController extends BaseController ...@@ -87,14 +90,14 @@ class CoinReleaseMemberController extends BaseController
public function actionImplode() public function actionImplode()
{ {
Yii::$app->response->format = 'json'; Yii::$app->response->format = 'json';
$file = UploadedFile::getInstanceByName('file'); $file = UploadedFile::getInstanceByName('file');
try { try {
$fd = fopen($file->tempName, 'r'); $fd = fopen($file->tempName, 'r');
$data = []; $data = [];
$rule_id = $this->getRuleId(); $rule_id = $this->getRuleId();
if ($rule_id) { if ($rule_id) {
$coin_publish_rule = CoinPublishRule::findOne($rule_id); $coin_publish_rule = CoinPublishRule::findOne($rule_id);
$present = $coin_publish_rule->lock; $present = $coin_publish_rule->lock;
if (!$coin_publish_rule) { if (!$coin_publish_rule) {
return ['code' => -1, 'msg' => '规则不存在']; return ['code' => -1, 'msg' => '规则不存在'];
} }
...@@ -127,6 +130,7 @@ class CoinReleaseMemberController extends BaseController ...@@ -127,6 +130,7 @@ class CoinReleaseMemberController extends BaseController
/** /**
* 获取rule_id * 获取rule_id
*
* @return int * @return int
*/ */
private function getRuleId() private function getRuleId()
......
...@@ -23,7 +23,7 @@ ListAsset::register($this); ...@@ -23,7 +23,7 @@ ListAsset::register($this);
<tr> <tr>
<td><?= $coin_name ?></td> <td><?= $coin_name ?></td>
<td><?= $amount / 1e8 ?></td> <td><?= $amount / 1e8 ?></td>
<td><?= $release_amount ?></td> <td><?= $release_amount / 1e8 ?></td>
<td><?= $address ?></td> <td><?= $address ?></td>
</tr> </tr>
</tbody> </tbody>
......
...@@ -9,9 +9,21 @@ table.render({ ...@@ -9,9 +9,21 @@ table.render({
cols: [[ cols: [[
{field: 'mobile', title: '手机号'}, {field: 'mobile', title: '手机号'},
{field: 'coin', title: '币种'}, {field: 'coin', title: '币种'},
{field: 'amount', title: '总量'}, {
{field: 'release', title: '已解冻'}, field: 'amount', title: '总量', templet: function (d) {
{field: 'freeze', title: '已冻结'}, return d.amount / 1e8;
}
},
{
field: 'release', title: '已解冻', templet: function (d) {
return d.release / 1e8;
}
},
{
field: 'freeze', title: '已冻结', templet: function (d) {
return d.freeze / 1e8;
}
},
]] ]]
}); });
...@@ -29,7 +41,7 @@ upload.render({ ...@@ -29,7 +41,7 @@ upload.render({
} }
}); });
}, },
before: function(obj){ //obj参数包含的信息,跟 choose回调完全一致,可参见上文。 before: function (obj) { //obj参数包含的信息,跟 choose回调完全一致,可参见上文。
layer.load(); //上传loading layer.load(); //上传loading
} }
}); });
......
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