mapType = array(); $this->model = new \app\common\model\MoneyIn; $this->assign('typeList', $this->model->getTypeList()); } /** * 查看 * @return string|Json * @throws \think\Exception * @throws DbException */ public function index() { //设置过滤方法 $this->request->filter(['strip_tags', 'trim']); if (false === $this->request->isAjax()) { return $this->view->fetch(); } //如果发送的来源是 Selectpage,则转发到 Selectpage if ($this->request->request('keyField')) { return $this->selectpage(); } [$where, $sort, $order, $offset, $limit] = $this->buildparams(); //tab $type = $this->request->param('order_type/d'); if($type > 0) $this->mapType['order_type'] = $type; $list = $this->model->with('users,admins') ->where($where) ->where($this->mapType) ->order($sort, $order) ->paginate($limit); $result = ['total' => $list->total(), 'rows' => $list->items()]; return json($result); } /** * 充值订单审核 * @param $ids * @return string * @throws DbException * @throws \think\Exception */ public function review($ids = null, $status= 0) { $row = $this->model->get($ids); if (!$row) { $this->error(__('No Results were found')); } $result = false; Db::startTrans(); try { //充值 if ($status == $this->model::Success) { (new MoneyLog())->change($row->user_id, $row->amount, MoneyLog::Recharge, '', '充值'); } $result = $row->allowField(true)->save(['status' => $status, 'admin_id'=>$this->auth->id]); //累积充值金额 //(new Users())->where('id', $row->user_id)->setInc('money_in_sum', $row->amount); Db::commit(); } catch (ValidateException|PDOException $e) { Db::rollback(); $this->error($e->getMessage()); } if (false === $result) { $this->error(__('No rows were updated')); } $this->success(); } }