request->get('page', 1); $page_size = $this->request->get('page_size', 10); $tab = $this->request->get('tab', 'all'); $accountType = $this->request->get('accountType', ''); $where = []; if ($tab != 'all') { $where['inc_or_exp'] = $tab == 'income' ? 1 : 2; } if ($accountType) { $where['account_type'] = $accountType == 'amount' ? ['in', ['amount', 'freeze']] : $accountType; } $list = AccountLogService::getList($where, $page_size, 'id desc')->toArray(); $this->success('', $list); } catch (\Exception $e) { if ($e instanceof HttpResponseException) { throw $e; } $this->error($e->getMessage()); } } public function info() { $user_id = $this->auth->id ?? -1; $data = AccountService::getOne(['user_id' => $user_id]); $this->success('success', $data); } public function applyWithdraw() { try { $user_id = $this->auth->id ?? -1; $amount = $this->request->post('amount', 0); $name = $this->request->post('name', ''); // 验证参数 $error = $this->validate($this->request->post(), [ 'name' => 'require', 'amount' => 'require|number|between:1,500', ], [ 'name.require' => '微信真实姓名必填', 'amount.require' => '提现金额不正确', 'amount.number' => '提现金额必须为数字', 'amount.between' => '提现金额必须在1到500之间', ]); if (true !== $error) { throw new \Exception($error); } AccountWithdrawService::applyWithdraw($user_id, $amount, $name); $this->success('提现申请成功,1-3个工作日到账'); } catch (\Exception $e) { if ($e instanceof HttpResponseException) { throw $e; } $this->error($e->getMessage()); } } }