paymentService = $paymentService; $this->userService = $userService; $this->requestService = $requestService; } public function register(RequestInterface $request) { $token = $request->route('token'); $requestLog = $this->requestService->getRequestLogByToken($token); $params = $request->all(); Log::info('registerNotifyParams:', $params); $baofu = new Baofu(); if (!$baofu->notifyVerify($params, 'register')) { Log::info('registerNotifyVerifyFail: ' . $params); return $baofu->notifySuccess(); } $userId = $requestLog->getDataValue('userId'); $appId = $requestLog->app_id; $this->userService->rsyncUser($params['loginNo'], $appId, $userId); $result = $this->notify( $requestLog->getDataValue('notify_url'), $requestLog->app, [ 'user_id' => $params['loginNo'], ] ); $baofu->notifySuccess(); } public function bindCard(RequestInterface $request) { $token = $request->route('token'); $requestLog = $this->requestService->getRequestLogByToken($token); $params = $request->all(); Log::info('registerNotifyParams:', $params); $baofu = new Baofu(); if (!$baofu->notifyVerify($params, 'register')) { Log::info('registerNotifyVerifyFail: ' . $params); return $baofu->notifySuccess(); } $bindCardFlag = $params['bindCardFlag'] && $params['bindCardFlag'] != 'false' ? true : false; if ($bindCardFlag) { $this->userService->rsyncBankCards($params['loginNo']); } $result = $this->notify( $requestLog->getDataValue('notify_url'), $requestLog->app, [ 'bind_card_flag' => $bindCardFlag, 'user_id' => $params['loginNo'], ] ); $baofu->notifySuccess(); } protected function notify($url, $app, $data) { if (empty($url)) { return 'empty url'; } $params = [ 'app_id' => $app->app_id, 'nonce_str' => StringHelper::getRandomString(32), 'timestamp' => time(), ]; $params['data'] = json_encode($data); $params['sign'] = PlatformSigner::sign($params, $app->app_key); Log::info('notifyToOut params:', $params, 'platform'); Log::info('notifyToOut url:' . $url, [], 'platform'); $result = Notification::post($url, $params); Log::info('notifyToOut response:' . $result, [], 'platform'); return $result; } }