get_son_agency_account(); } //列表 public function index(Request $request, CheckOut $model) { $son_agency = $this->son_agency . ",{$this->user->username}"; $param = $request->param(); $model = $model->son($son_agency)->scope('where', $param); $data = $model->paginate($this->admin['per_page'], false, ['query' => $request->get()]); //关键词,排序等赋值 $this->assign($request->get()); $this->assign([ 'data' => $data, 'page' => $data->render(), 'total' => $data->total(), 'agency' => AgencyUser::Progeny($this->user)->scope('role')->field('id,username,invite')->all(), 'user' => $this->user, ]); return $this->fetch(); } public function param_add($agency_id, Request $request, CheckOut $model, CheckOutValidate $validate) { if (!$agency_id) { exception(lang('agency_select_error')); } $agency = AgencyUser::whereIn('id', $agency_id)->field('id,username,money')->find(); $bank_account = BankAccount::whereIn('agency_id', $agency_id)->find(); $enabled_money = round($agency['money'] - Config::get('game.retain'), 2); if ($request->isPost()) { $param = $request->param(); if ($param['money'] > $enabled_money) { admin_error(lang("balance_money_lack",[$enabled_money])); } $param['money'] = round($param['money'], 2); $param['tax'] = round(($param['money'] / 100) * Config::get('game.commission'), 2); $param['amount'] = round($param['money'] - $param['tax'], 2); $result = AgencyUser::whereIn('id', $agency_id)->setDec('money', $param['money']); if ($result) { $model::create($param) ? admin_success() : admin_error(); } } $this->assign([ 'agency' => $agency, 'bank_account' => $bank_account, 'enabled_money' => $enabled_money ]); return $this->fetch('add'); } //删除 public function del($id, CheckOut $model) { if (count($model->noDeletionId) > 0) { if (is_array($id)) { if (array_intersect($model->noDeletionId, $id)) { return admin_error('ID为' . implode(',', $model->noDeletionId) . '的数据无法删除'); } } else if (in_array($id, $model->noDeletionId)) { return admin_error('ID为' . $id . '的数据无法删除'); } } if ($model->softDelete) { $result = $model->whereIn('id', $id)->useSoftDelete('delete_time', time())->delete(); } else { $result = $model->whereIn('id', $id)->delete(); } return $result ? admin_success('操作成功', URL_RELOAD) : admin_error(); } public function enable($id, CheckOut $model) { $result = $model->whereIn('id', $id)->update(['status' => 1, 'update_time' => time()]); return $result ? admin_success('操作成功', URL_RELOAD) : admin_error(); } }