...
|
...
|
@@ -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();
|
|
|
}
|
|
|
} |
...
|
...
|
|