validate([ 'refund_id' => 'required', ]); $this->refundApply = RefundApply::find(request()->input('refund_id')); if (!isset($this->refundApply)) { throw new AdminException('退款记录不存在'); } } public function api() { $request = request()->input(); try { $result = \Illuminate\Support\Facades\DB::transaction(function () use ($request) { $result = (new RefundService)->pay($request['refund_id']); if (!$result) { throw new AppException('操作失败'); } return $result; }); } catch (\Exception $e) { \Log::debug('<------售后退款失败------:'.$e->getMessage()); throw new AppException($e->getMessage()); } return $this->successJson('退款成功'); } /** * {@inheritdoc} */ public function index() { $request = request()->input(); $this->validate([ 'refund_id' => 'required' ]); $restrictAccess = \app\common\services\RequestTokenService::limitRepeat('agree_refund_'. $request['refund_id']); if (!$restrictAccess) { throw new ShopException('短时间内重复操作,请等待10秒后再操作'); } try { /** * @var $this ->refundApply RefundApply */ $result = \Illuminate\Support\Facades\DB::transaction(function () use ($request) { $result = (new RefundService)->pay($request['refund_id']); if (!$result) { throw new ShopException('操作失败'); } return $result; }); } catch (\Exception $e) { \Log::debug('<------售后退款失败------:'.$e->getMessage()); throw new ShopException($e->getMessage()); } if (is_string($result)) { redirect($result)->send(); } if (is_array($result) && isset($result['action']) && isset($result['input'])) { echo $this->formPost($result);exit(); } // RefundMessageService::passMessage($this->refundApply);//通知买家 // // event(new AfterOrderRefundSuccessEvent($this->refundApply)); // if (app('plugins')->isEnabled('instation-message')) { // event(new \Yunshop\InstationMessage\event\OrderRefundSuccessEvent($this->refundApply)); // } return $this->message('操作成功'); } /** * 表单POST请求 * @param $trxCode * @param $data */ public function formPost($data) { $echo = ""; $echo .= ""; echo $echo; } }