request->getQueryParams(); $post = $this->request->getParsedBody(); $cookie = $this->request->getCookieParams(); $files = $this->request->getUploadedFiles(); $server = $this->request->getServerParams(); $xml = $this->request->getBody()->getContents(); $app['request'] = new Request($get,$post,[],$cookie,$files,$server,$xml); /* 通知回调,进行业务处理 */ $response = $app->handleRefundedNotify(function ($message, $fail) use ($app) { try { /* --- 退款失败 --- */ if ( empty($message) || !isset($message['result_code']) || $message['result_code'] != 'SUCCESS' ) { // 错误日志 $this->log->event( LogLabel::PAY_NOTIFY_REFUND, $message ); $fail('Unknown error but FAIL'); } /* --- 退款成功 --- */ $orderMain = OrderMain::select('id','global_order_id','money','user_id') ->where('global_order_id',$message['out_trade_no']) ->where('state',OrderMain::ORDER_STATE_REFUNDED) ->first(); // 退款返还优惠券 $this->couponService->orderRefundCoupon($message['out_trade_no']); // 删除特价商品缓存 $this->purchaseLimitService->delSsdbPurchaseRecord($orderMain->id); // 添加用户的流水 if(!empty($orderMain)){ $this->financialService->userByOLOrderRefund($orderMain->user_id, $orderMain->global_order_id, $orderMain->money); } } catch (\Exception $e) { $this->log->event( LogLabel::PAY_NOTIFY_REFUND, ['exception_fail' => $e->getMessage()] ); $fail('Exception'); } }); // return $this->response // ->withHeader('Content-Type', 'text/xml') // ->withStatus(200) // ->withBody(new SwooleStream($response->getContent())); } }