作者 刘朕
1 个管道 的构建 通过 耗费 1 秒

合并分支 'Branch_liuzhen' 到 'master'

Branch liuzhen



查看合并请求 !367
... ... @@ -211,4 +211,77 @@ class Store extends Backend
$this->view->assign('row',$row);
return $this->view->fetch();
}
/**
* 调整焦点币
*/
public function score_edit($ids = null)
{
$row = $this->model->get($ids);
if (!$row) {
$this->error(__('No Results were found'));
}
$adminIds = $this->getDataLimitAdminIds();
if (is_array($adminIds)) {
if (!in_array($row[$this->dataLimitField], $adminIds)) {
$this->error(__('You have no permission'));
}
}
$user = Db::name('user')->where('id',$row->user_id)->find();
if ($this->request->isPost()) {
$params = $this->request->post("row/a");
if ($params) {
$params = $this->preExcludeFields($params);
if($params['type'] == 1) {
} else {
if($user['score'] < $params['score']) {
$this->error('该商家焦点币余额不足');
}
}
$result = $res_log = false;
Db::startTrans();
try {
if($params['type'] == 1) {
$result = Db::name('user')->where('id',$user['id'])->setInc('score',$params['score']);
$after = bcadd($user['score'],$params['score'],0);
$memo = '平台代充焦点币';
} else {
$result = Db::name('user')->where('id',$user['id'])->setDec('score',$params['score']);
$after = bcsub($user['score'],$params['score'],0);
$memo = '平台扣除焦点币';
}
$score_log = [
'user_id' => $user['id'],
'score' => $params['score'],
'before' => $user['score'],
'after' => $after,
'status' => 2,
'memo' => $memo,
'createtime' => time()
];
$res_log = Db::name('user_score_log')->insertGetId($score_log);
// $result = $row->allowField(true)->save($params);
Db::commit();
} catch (ValidateException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (PDOException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (\Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if ($result !== false || $res_log !== false) {
$this->success();
} else {
$this->error(__('No rows were updated'));
}
}
$this->error(__('Parameter %s can not be empty', ''));
}
$row->score = $user['score'];
$this->view->assign("row", $row);
return $this->view->fetch();
}
}
... ...
... ... @@ -25,6 +25,11 @@ return [
'Createtime' => '生成时间',
'Updatetime' => '更新时间',
'Admin.nickname' => '昵称',
'Type' => '类型',
'Type 1' => '增加',
'Type 2' => '扣除',
'Now_score' => '当前焦点币',
'Score' => '焦点比数量',
'Username' => '后台账号',
'Password' => '后台密码',
'User.nickname' => '昵称',
... ...
... ... @@ -33,6 +33,8 @@
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
data-operate-score_edit="{:$auth->check('store/store/score_edit')}"
data-operate-house="{:$auth->check('store/store_house/index')}"
data-operate-examine="{:$auth->check('store/store/examine')}"
data-operate-edit="{:$auth->check('store/store/edit')}"
data-operate-del="{:$auth->check('store/store/del')}"
... ...
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Now_score')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="radio">
{$row.score}
</div>
</div>
</div>
<div class="form-group">
<label for="type" class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
<div class="col-xs-12 col-sm-8">
{:build_radios('row[type]', [1=>__('Type 1'), 2=>__('Type 2')], 1)}
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Score')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-score" data-rule="required" class="form-control" name="row[score]" type="number" value="">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
... ...
... ... @@ -13,6 +13,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
examine_url: 'store/store/examine',
inform_url: 'store/store_inform/index',
house_url: 'store/store_house/index',
score_edit_url: 'store/store/score_edit',
table: 'store',
}
});
... ... @@ -107,6 +108,22 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
return false;
}
},
},
{
name: 'score_edit',
text: '调整焦点币',
title: '调整焦点币',
classname: 'btn btn-xs btn-primary btn-dialog',
icon: '',
url: $.fn.bootstrapTable.defaults.extend.score_edit_url,
extend:"data-area='[\"50%\",\"60%\"]'",
visible:function (row) {
if(row.status == 3){
return true;
}else{
return false;
}
},
}
], formatter: Table.api.formatter.operate}
]
... ... @@ -123,6 +140,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
Controller.api.change();
Controller.api.bindevent();
},
score_edit: function() {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
... ...