/** * 获取账户余额 */ public function getBalance($userId, $userAccountId = "") { $result = array('status' => false, 'msg' => '', 'balance' => 0); if (empty($userId)) { $result['msg'] = "userId参数不正确"; return $result; } if (empty($userAccountId)) { // 获取到支付账户Id $accountId = Bll_Fyk_Payment_User::getInstance()->getUserAccountId($userId); } else { $accountId = $userAccountId; } $count = 0; while (true) { if ($count >= 3) { break; } // 调用api,开始 $params = array('account' => $accountId); $configPayment = Const_PaymentApp::FYK; $apiResult = Bll_Service_Payment::inquiry($configPayment, $params); if ($apiResult->isSucceeded()) { if ($apiResult['status'] == 'ok') { $result['status'] = true; $result['balance'] = !empty($apiResult['data']) ? $apiResult['data']['balance'] : 0; break; } else { $count++; } } else { $result['msg'] = '链接失败'; $count++; } } return $result; }