Commit 5900266d authored by ZhuChunYang's avatar ZhuChunYang

旷工费修改

parent f226bbe7
......@@ -107,8 +107,8 @@ class ServiceController extends BaseController
if(!$coin){
return ['code' => 1,'data' => [],'msg' => '币种不能为空'];
}
$fee = MinerFee::find()->where(['platform' => $coin,'type' => 2])->asArray()->one();
if(!$fee || !$fee['min']){
$fee = MinerFee::find()->where(['platform' => $coin,'type' => 2])->select('id,platform,type,fee,create_at,update_at')->asArray()->one();
if(!$fee){
return ['code' => 1,'data' => [],'msg' => '旷工费未设置'];
}
return ['code' => 0,'data' => $fee,'msg' => '旷工费获取成功'];
......
......@@ -170,4 +170,26 @@ class MinerFeeController extends BaseController
return ['code' => 0, 'msg' => '币种库更新成功'];
}
}
public function actionSetFee()
{
if (Yii::$app->request->isAjax) {
Yii::$app->response->format = 'json';
$request = Yii::$app->request;
$id = $request->get('id', '');
$fee = $request->get('fee',0);
if($id){
$minerFee = MinerFee::find()->where(['id' => $id])->one();
if(!$minerFee){
return ['code' => 1,'msg' =>'币种旷工费异常'];
}
$minerFee->fee = $fee;
$minerFee->update_at = date('Y-m-d H:i:s');
$minerFee->save();
return ['code' => 0,'msg' => '旷工费设置成功'];
}else{
return ['code' => 1 ,'msg' => '旷工费设置失败'];
}
}
}
}
\ No newline at end of file
......@@ -26,7 +26,7 @@
</div>
<div class="layui-tab-item">
<button class="layui-btn layui-btn-default" id="update-coin">更新币种库</button>
<table class="layui-table" id="table2" ></table>
<table class="layui-table" id="table2" lay-filter="table2" ></table>
</div>
</div>
......@@ -56,12 +56,9 @@
cols: [[
{field: 'id', title: 'ID'},
{field: 'platform', title: '币种'},
{field: 'min', title: '最小值'},
{field: 'max', title: '最大值'},
{field: 'level', title: '分档'},
{field: 'fee', title: '旷工费' ,edit: 'text'},
{field: 'create_at', title: '创建时间'},
{field: 'update_at', title: '更新时间'},
{field: 'id', title: '操作', templet: "#operatorTpl"}
]],
url: '/admin/miner-fee/cost?type=2'
});
......@@ -77,7 +74,21 @@
});
}
});
})
});
//监听单元格编辑
table.on('edit(table2)', function(obj){
var value = obj.value; //得到修改后的值
var data = obj.data; //得到所在行所有键值
$.get('/admin/miner-fee/set-fee', {id:data.id,fee:value}, function(rev) {
layer.msg(rev.msg);
if (0 == rev.code) {
table.reload('table2',{});
}else{
}
});
});
</script>
<script type="text/html" id="operatorTpl">
<a href="/admin/miner-fee/edit?id={{d.id}}&type={{d.type}}">
......
......@@ -40,4 +40,5 @@ class MinerFee extends BaseActiveRecord
$data = $query->offset(($page - 1) * 10)->limit($limit)->asArray()->all();
return ['count' => $count, 'data' => $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