/** * 调用扣费api * @param $userId * @param $reqId * @param $price * @param $note * @return array */ public function callCosumeApi($userId, $reqId, $price, $note) { $result = array('status' => false, 'msg' => '', 'apiData' => ''); $count = 0; while (true) { if ($count >= 3) { break; } // 调用api,开始扣费 $params = array('canOverruns' => 0, 'note' => $note, 'amount' => $price, 'reqId' => $reqId, 'userId' => $userId); $configPayment = Const_PaymentApp::AJK_ENTRUST; $apiResult = Bll_Service_Payment::fixUse($configPayment, $params); if ($apiResult->isSucceeded()) { $transferInfo = $apiResult->getTransferInfo(); if ($apiResult['status'] == 'ok') { $result['status'] = true; $result['apiData'] = array('response' => $apiResult->getResponse(), 'transferInfo' => array('url' => $transferInfo['url'], 'content_type' => $transferInfo['content_type'], 'http_code' => $transferInfo['http_code'])); break; } else { $result['apiData'] = array('response' => $apiResult->getResponse(), 'transferInfo' => array('url' => $transferInfo['url'], 'content_type' => $transferInfo['content_type'], 'http_code' => $transferInfo['http_code'])); $count++; } } else { $result['msg'] = '链接失败'; $count++; } } return $result; }
/** * 调用扣费api anbi 扣费 * @param $brokerId * @param $userId * @param $reqId * @param $price * @return array */ public function chargeMoneyByAnbi($brokerId, $userId, $reqId, $price) { $result = array('status' => false, 'msg' => '', 'apiData' => ''); if (empty($brokerId) || empty($userId) || empty($price) || empty($reqId)) { $result['msg'] = "参数不正确"; return $result; } $count = 0; $note = date("Y-m-d") . "购买抢客劵扣费"; while (true) { if ($count >= 3) { break; } // 调用api,开始扣费 $params = array('canOverruns' => 0, 'note' => $note, 'amount' => $price, 'reqId' => $reqId, 'userId' => $userId); $configPayment = Const_PaymentApp::CUSTOMER_ANBI; $apiResult = Bll_Service_Payment::fixUse($configPayment, $params); if ($apiResult->isSucceeded()) { $transferInfo = $apiResult->getTransferInfo(); if ($apiResult['status'] == 'ok') { $result['status'] = true; $result['apiData'] = array('response' => $apiResult->getResponse(), 'transferInfo' => array('url' => $transferInfo['url'], 'content_type' => $transferInfo['content_type'], 'http_code' => $transferInfo['http_code'])); break; } else { $result['apiData'] = array('response' => $apiResult->getResponse(), 'transferInfo' => array('url' => $transferInfo['url'], 'content_type' => $transferInfo['content_type'], 'http_code' => $transferInfo['http_code'])); $count++; } } else { $result['msg'] = '链接失败'; $count++; } } // 记录请求支付中心日志 $addLogArr = array('brokerId' => $brokerId, 'accountId' => 0, 'price' => $price, 'requestId' => $reqId, 'status' => $result['status'] ? 1 : 2, 'msg' => json_encode($result), 'createTime' => time()); Bll_CustomerRush_Payment_Log::getInstance()->insertAcenterRequestLog($addLogArr); return $result; }
/** * 调用扣费api * @param $userId * @param $reqId * @param $price * @param $note * @return array */ public function callCosumeApi($userId, $reqId, $price, $dateIndex, $dataBase) { $result = array('status' => false, 'msg' => '', 'apiData' => ''); $dataBaseName = ""; if ($dataBase == Const_ShowcaseOrders::SALE_DB) { $configPayment = Const_PaymentApp::AJK_SHOWCASE; $dataBaseName = "二手房"; } else { if ($dataBase == Const_ShowcaseOrders::RENT_DB) { $configPayment = Const_PaymentApp::HZ_SHOWCASE; $dataBaseName = "租房"; } else { return $result; } } $count = 0; $note = date("Y-m-d", strtotime($dateIndex)) . "橱窗展示扣费(" . $dataBaseName . ")"; while (true) { if ($count >= 3) { break; } // 调用api,开始扣费 $params = array('canOverruns' => 0, 'note' => $note, 'amount' => $price, 'reqId' => $reqId, 'userId' => $userId); $apiResult = Bll_Service_Payment::fixUse($configPayment, $params); if ($apiResult->isSucceeded()) { $transferInfo = $apiResult->getTransferInfo(); if ($apiResult['status'] == 'ok') { $result['status'] = true; $result['apiData'] = array('response' => $apiResult->getResponse(), 'transferInfo' => array('url' => $transferInfo['url'], 'content_type' => $transferInfo['content_type'], 'http_code' => $transferInfo['http_code'])); break; } else { $result['apiData'] = array('response' => $apiResult->getResponse(), 'transferInfo' => array('url' => $transferInfo['url'], 'content_type' => $transferInfo['content_type'], 'http_code' => $transferInfo['http_code'])); $count++; } } else { $result['msg'] = '链接失败'; $count++; } } return $result; }