auditedRebut(); if ($result == true) { event(new BalanceWithdrawRejectEvent($this->withdrawModel)); // BalanceNoticeService::withdrawRejectNotice($this->withdrawModel); return $this->message('驳回成功', yzWebUrl("withdraw.detail.index", ['id' => $this->withdrawModel->id])); } return $this->message('驳回失败,请刷新重试', yzWebUrl("withdraw.detail.index", ['id' => $this->withdrawModel->id]), 'error'); } public function validatorWithdrawModel($withdrawModel) { if (!in_array($withdrawModel->status, [Withdraw::STATUS_INITIAL, Withdraw::STATUS_AUDIT, Withdraw::STATUS_INVALID])) { throw new ShopException('状态错误,不符合驳回规则!'); } } /** * @return bool */ private function auditedRebut() { DB::transaction(function () { $this->_auditedRebut(); }); return true; } /** * @throws ShopException */ private function _auditedRebut() { $result = $this->updateWithdrawStatus(); if (!$result) { throw new ShopException('驳回失败:更新状态失败'); } $result = $this->updateBalance(); if (!$result) { throw new ShopException('驳回失败:更新余额明细失败'); } } /** * @return bool */ private function updateWithdrawStatus() { $this->withdrawModel->status = Withdraw::STATUS_REBUT; $this->withdrawModel->reject_reason = request()->reject_reason ? : ''; $this->withdrawModel->arrival_at = time(); return $this->withdrawModel->save(); } private function updateBalance() { $data = array( 'member_id' => $this->withdrawModel->member_id, 'change_value' => $this->withdrawModel->amounts, 'operator' => ConstService::OPERATOR_SHOP, 'operator_id' => \YunShop::app()->uid, 'remark' => '余额提现驳回' . $amounts = $this->withdrawModel->amounts . "元", 'relation' => $this->withdrawModel->withdraw_sn, ); $result = (new BalanceChange())->rejected($data); if ($result === true) { return true; } return false; } }