/** * 调用扣费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; }
public function prepareParams($params) { $params = parent::prepareParams($params); $params['appid'] = $this->appId; $params['appkey'] = $this->appKey; return $params; }
/** * 创建账户 */ private function createAccount($userId) { $result = array('status' => false, 'msg' => '', 'accountId' => ''); $count = 0; while (true) { if ($count >= 3) { break; } // 调用api,开始扣费 $params = array('action' => 'create', 'uid' => $userId); $configPayment = Const_PaymentApp::FYK; $apiResult = Bll_Service_Payment::createAccount($configPayment, $params); if ($apiResult->isSucceeded()) { if ($apiResult['account']) { $result['status'] = true; $result['accountId'] = $apiResult['account']; break; } else { $count++; } } else { $result['msg'] = '链接失败'; $count++; } } return $result; }
/** * 获取账户信息 * @param $ajkBrokerId * @param string $field * 可能值 * => all * balance=> 余额, * frozen=> 冻结总额, * jp|hz|ajk => 对应分站的余额 冻结 金额信息 * @return array */ public static function getAccountInfo($ajkBrokerId, $field = '*') { $userId = Bll_Broker_MainBusiness::getDataByEsfId($ajkBrokerId)->memberId; $response = Bll_Service_Payment::balance(Const_PaymentApp::AJK_DEFAULT, array('userId' => $userId)); if ($response->isFailed()) { return Util_GlobalFunc::buildReturn(0, '获取账户余额失败,请求内部API失败.'); } if ($response['status'] == 'error') { return Util_GlobalFunc::buildReturn(0, '获取账户余额失败' . $response['info']); } $data = $field == '*' ? $response['data'] : $response['data'][$field]; return Util_GlobalFunc::buildReturn(1, $data); }
/** * @override */ public function request($params = array()) { $response = parent::request($params); // 对于由于经纪人账户未创建导致的获取经纪人账户余额错误,决定默认返回成功的结果 if ($response->isSucceeded() && $response['status'] == 'error' && $response['code'] == '503198') { $newResponse = new Bll_Service_Client_HttpResponse(); $newResponse->setTransferInfo($response->getTransferInfo()); $newResponse->succeed(); $newResponse->setResponse(array('status' => 'ok', 'data' => array('balance' => 0, 'frozen' => 0, 'personBalance' => 0, 'companyBalance' => 0, 'jp' => array('id' => 0, 'balance' => 0, 'frozen' => 0), 'hz' => array('id' => 0, 'balance' => 0, 'frozen' => 0), 'ajk' => array('id' => 0, 'balance' => 0, 'frozen' => 0)))); $response = $newResponse; } return $response; }
public function handle_request_internal() { $brokerId = $this->_params['brokerId']; $app = $this->_params['app']; $brokerInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId); if (!$brokerInfo) { throw new Exception_BrokerNotFoundException('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS); } /** 获取经纪人被关注的人数 */ $brokerChatId = Model_Mobile_BrokerChatInfo::getBrokerChatInfo($brokerId, array('chatId')); $followerNum = 0; if ($brokerChatId['chatId']) { $followerNumInfo = Bll_Mobile_ChatInfoBll::getBrokerFollowerNum($brokerChatId['chatId']); if ($followerNumInfo['data']['status'] == 'OK') { $followerNum = $followerNumInfo['data']['result']['focus_count']; } } $analysis = Bll_Broker_CallAnalysis::getBrokerAnalysis($brokerId); $balanceInfo = Bll_Service_Payment::balance(Bll_Service_Payment::SITE_ANJUKE, array('userId' => Bll_Broker_MainBusiness::getDataByEsfId($brokerId)->memberId)); $managerInfo = Bll_Broker::getWorkerNumInfo($brokerId); // 微聊达人 $isTalent = -1; // 默认,微聊活动未开始或已结束 if (Bll_Broker_CallAnalysis::isTalentEventOngoing()) { $isTalent = 0; // 活动中,默认不是微聊达人 if ($analysis) { $isTalent = $analysis['isTalent']; } } $talentIcon = Bll_Broker_CallAnalysis::getTalentIcon($isTalent, $app); // 明星经纪人 $isStarBroker = 0; $starBrokerIcon = ''; try { $bllStarBroker = new Bll_Broker_StarIntermediary($brokerInfo['cityId']); $starBrokerInfo = $bllStarBroker->getBrokerNewestInfo($brokerId); if ($starBrokerInfo && $starBrokerInfo['broker']['isMingxing']) { $isStarBroker = 1; $starBrokerIcon = PageHelper::pure_static_url('/img/mobile/app/star_broker.png'); } } catch (Exception $e) { // do nothing } return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('replyRate' => $analysis['reply5minRate'] * 100, 'responseTime' => $analysis['avgRespondTime'], 'customNum' => $analysis['accChatUser'], 'loginDays' => $analysis['accLoginDays'], 'isTalent' => $isTalent, 'talentIcon' => $talentIcon, 'isStarBroker' => $isStarBroker, 'starBrokerIcon' => $starBrokerIcon, 'ajkContact' => $managerInfo['userName'], 'balance' => empty($balanceInfo['data']['balance']) ? 0 : round($balanceInfo['data']['balance'] / 100, 2), 'tel' => $managerInfo['mobile'], 'followerNum' => $followerNum)); }
/** * 帐号解冻。 * @param int $user_id 二手房用户ID。 * @param int $amount 消费金额 * @param int $proid 房源ID * @param string $app 引用的业务。可能值:JP,ZF,AJK * @param int $sn 流水号 * @param string $note 备注信息 * @param bool $newFrozen 是否使用新的扣费程序 * @param bool|string $requestId 是否使用外部requestId * @return string $sn */ public static function cancel_frozen($user_id, $amount, $proid, $app, $sn, $note = '', $newFrozen = false, $requestId = false) { $ret = FALSE; // 新扣费程序 if ($newFrozen) { $info = Bll_Service_Payment::bidUnfreeze($app, array('userId' => $user_id, 'reqId' => $requestId ? $requestId : self::get_reqid($proid, $app), 'amount' => (int) ($amount * 100), 'frozenSN' => $sn, 'note' => $note)); return strcasecmp(trim($info['status']), 'ok') == 0 || $info['code'] == 398507; } else { $url_path = 'use'; $params = array('userId' => $user_id, 'reqId' => $requestId ? $requestId : self::get_reqid($proid, $app), 'amount' => (int) ($amount * 100), 'frozenSN' => $sn, 'note' => $note); $info = Util_CallAPI::call_internal_exes_api($url_path, 'hz_bid', $params); if ($info['data']['status'] === 'ok') { $ret = $info['data']['data']['sn']; } } return $ret; }
public function handle_request_internal() { $brokerInfo = self::$BrokerInfo['BaseInfo']; //经纪人信息 if ($brokerInfo['PAYTYPE'] != 9999) { APF::get_instance()->get_response()->redirect('/user/combo/brokerhome'); exit; } $updateCombos = Bll_Combo_Broker_BrokerComboInfo::getBrokerComboForUpdate(self::$intUserID); $this->out['updateCombos'] = $updateCombos; //账户余额 $balance = Bll_Service_Payment::balance(Bll_Service_Payment::SITE_ANJUKE, array('userId' => self::$intUserID)); $balancePerson = round($balance['data']['personBalance'] / 100, 2); //账户余额(个人) $this->out['balancePerson'] = $balancePerson; $this->setAttribute('out', $this->out); return 'Combo_Update_Update'; }
public function handle_request_internal() { if ($this->_params['demon']) { goto demon; } $brokerId = $this->_params['brokerId']; try { $brokerBaseInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId); $balanceResponse = Bll_Service_Payment::balance(Bll_Service_Payment::SITE_ANJUKE, array('userId' => $brokerBaseInfo->userId)); if (empty($balanceResponse) || $balanceResponse['status'] != 'ok') { throw new Exception(self::NET_ERROR_MSG, self::NET_ERROR); } $balance = $balanceResponse['data']['balance']; $frozen = $balanceResponse['data']['frozen']; $personBalance = $balanceResponse['data']['personBalance']; $companyBalance = $balanceResponse['data']['companyBalance']; } catch (Exception $e) { return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => $e->getCode(), 'message' => $e->getMessage()); } return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('balance' => $balance / 100, 'frozen' => $frozen / 100, 'personBalance' => $personBalance / 100, 'companyBalance' => $companyBalance / 100, 'balanceUnit' => '元', 'otherUnit' => '安币')); demon: return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('balance' => 263.1, 'frozen' => 40, 'personBalance' => 50, 'companyBalance' => 60, 'balanceUnit' => '元', 'otherUnit' => '安币')); }
public function handle_request_internal() { if (!$this->isBrokerLogin()) { $this->redirect_to_login(); } /** * @var $request AJKRequest */ $request = APF::get_instance()->get_request(); $cityId = $request->getBrokerCityId(); $brokerId = $request->getBrokerId(); $userId = $request->getUserId(); $brokerInfo = self::$BrokerInfo['BaseInfo']; //非套餐经纪人不能进入该页面,跳转到首页 if ($brokerInfo['PAYTYPE'] != 9999) { $this->redirect('/user/broker/brokerhome'); } $companyId = intval($brokerInfo['COMPANYID']); if ($companyId > 0) { /** 通过配置文件配置那些城市的非独立经纪人不可以购买月套餐 */ $canNotBuyMonthlyComboCitySet = APF::get_instance()->get_config('can_not_buy_monthly_combo_city_set'); if (is_array($canNotBuyMonthlyComboCitySet) && in_array($cityId, $canNotBuyMonthlyComboCitySet)) { $companyId = 0; } } //获取城市可选择的套餐列表 if ($companyId > 0) { $comboList = Bll_Combo_Broker_BrokerComboInfo::getCompanyComboList($cityId, $companyId); } else { $comboList = Bll_Combo_Broker_BrokerComboInfo::getComboList($cityId); } //获取经纪人当前套餐 $brokerCombos = Bll_Combo_Broker_BrokerComboInfo::getBrokerComboList($brokerId); //查询账户余额 $balance = Bll_Service_Payment::balance(Bll_Service_Payment::SITE_ANJUKE, array('userId' => $userId)); $UserAccountAll = $balance['data']['balance'] / 100.0; //账户余额 $UserAccountPerson = $balance['data']['personBalance'] / 100.0; //账户余额(个人) $UserAccountCompany = $balance['data']['companyBalance'] / 100.0; //账户余额(公司) /** * 获取经纪人信息身份认证状态(购买套餐时需要身份认证通过) * CheckState - 经纪人身份认证状态 * OperateState - 经纪人审核过程中走到哪一步标记 * * 备注:本处会出bug。(后台显示身份认证通过、不能购买套餐) * 经纪人后台判断身份认证状态只使用CheckState=1 * 套餐购买的api里面判断CheckState=1 && OperateState=4 * api组的志山同志拍脑袋,使用双验证。 * caoyang 20140825 */ //$brokerInfo['CheckState'] = ($brokerInfo['CHECKSTATE'] == 1 && $brokerInfo['OPERATESTATE'] == 4) ? 1 : 0; $brokerInfo['CheckState'] = $brokerInfo['CHECKSTATE']; $this->setAttribute('comboList', $comboList); $this->setAttribute('brokerCombos', $brokerCombos); $this->setAttribute('UserAccountAll', number_format($UserAccountAll, 2, ".", "")); $this->setAttribute('UserAccountPerson', number_format($UserAccountPerson, 2, ".", "")); $this->setAttribute('UserAccountCompany', number_format($UserAccountCompany, 2, ".", "")); $this->setAttribute('brokerInfo', $brokerInfo); return 'Combo_Buy_Select'; }
private static function get_broker_balance_by_broker_id($broker_id) { $userId = Bll_Broker_MainBusiness::getDataByEsfId($broker_id)->memberId; $balanceInfo = Bll_Service_Payment::balance(Bll_Service_Payment::SITE_ANJUKE, array('userId' => $userId)); if ($balanceInfo['status'] == 'error') { return -1; } $balance = 0; if (isset($balanceInfo['data']['hz']['balance'])) { $balance = $balance + intval($balanceInfo['data']['hz']['balance']); } if (isset($balanceInfo['data']['ajk']['balance'])) { $balance = $balance + intval($balanceInfo['data']['ajk']['balance']); } if (isset($balanceInfo['data']['jp']['balance'])) { $balance = $balance + intval($balanceInfo['data']['jp']['balance']); } return $balance; }
public function setApp($app) { if (!is_string($app)) { throw new Bll_Service_Exception('Invalid App Name'); } if (is_null(self::$apps)) { self::$apps = APF::get_instance()->get_config('apps', 'acenter'); } if (!isset(self::$apps[$app])) { throw new Bll_Service_Exception('Cannot find config for app:' . $app); } // 加载appId和appKey $this->app = $app; $this->appId = self::$apps[$this->app]['appId']; $this->appKey = self::$apps[$this->app]['appKey']; return $this; }
/** * 303竞价结算 * 1. 查询经纪人所有有效计划, * 没有计划return * * 2. 基于推广计划,查询计划下有效房源(循环计划查询) * * 判断计划状态 * 推广中,contine * 第二天推广,continue * 手动停止,continue * 账户限额不足,计划置为推广中,记录计划推广日志 * 查询计划下房源关系, * 如果为空,contine * 不为空,判断计划状态 * 如果账户余额不足,记录房源推广日志 */ public static function broker_frozen_money($params) { if (empty($params['broker_id'])) { return Bll_JpPropBll::build_return(1, array("经纪人ID为空")); } $returnLog = array(); //获取账户余额 try { $userId = Bll_Broker_MainBusiness::getDataByEsfId($params['broker_id'])->memberId; $balance = Bll_Service_Payment::balance(Bll_Service_Payment::SITE_ANJUKE, array('userId' => $userId)); } catch (Exception $e) { array_push($returnLog, "获取账户余额不足失败"); return Bll_JpPropBll::build_return(0, $returnLog); } if ($balance['data']['balance'] <= 0) { array_push($returnLog, "当前账户余额不足"); return Bll_JpPropBll::build_return(1, $returnLog); } array_push($returnLog, "当前账户余额:" . $balance['data']['balance']); //获取经纪人正在推广的计划 $StaticPricePlanList = DAO_Plan_StaticPricePlan::getStaticPricePlanListByBrokerId($params['broker_id']); foreach ($StaticPricePlanList as $list) { if ($list['Status'] != 1) { //无效的计划 array_push($returnLog, "无效的计划:" . $list['Id'] . ";"); continue; } if ($list['ViewTime'] != 1893427200) { //非账户没钱停止的计划 array_push($returnLog, "计划Id:" . $list['Id'] . "展示时间:" . date("Y-m-d H:i:s", $list['ViewTime']) . ";"); continue; } $tmpStr = "计划Id:" . $list['Id'] . "展示时间:" . date("Y-m-d H:i:s", $list['ViewTime']) . ";"; //获取计划下面的房源 $StaticPriceRelation = DAO_Plan_StaticPriceRelation::getProSpreadRelation($list['Id'], $list['CityId']); //更新计划的状态 if (BLL_Fixedspread_StaticPlanUpDownSwicher::isOnline()) { DAO_Plan_StaticPricePlan::updateStaticPricePlanById(array('Id' => $list['Id'], 'ViewTime' => time())); } //记录计划日志 $params['plan_id'] = $list['Id']; $data = self::build_plan_log($params, 8, "账户有钱计划推广,动作id:" . $params['id'], $params['broker_id']); if (!Model_House_UpDown_PlanLog::create($data, date('m'))->save()) { array_push($returnLog, "账户有钱计划推广日志写入失败"); return Bll_JpPropBll::build_return(0, $returnLog); } //记录房源日志 foreach ($StaticPriceRelation as $Relation) { $params['pro_id'] = $Relation['ProId']; $data = Bll_EsfPropBll::build_prop_log($params, 5, "房源推广,动作id:" . $params['id'], $params['broker_id']); if (!Model_Log_HouseLogNew::create($data, date('Ymd'))->save()) { array_push($returnLog, "房源" . $Relation['ProId'] . "房源推广日志写入失败"); return Bll_JpPropBll::build_return(0, $returnLog); } $tmpStr .= $Relation['ProId'] . ","; } array_push($returnLog, $tmpStr); } if (empty($returnLog)) { array_push($returnLog, "经纪人没有计划"); } return Bll_JpPropBll::build_return(1, $returnLog); }
public function handle_request_internal() { if (!$this->isBrokerLogin()) { $this->redirect_to_login(); } $apf = APF::get_instance(); $request = APF::get_instance()->get_request(); $objResponse = APF::get_instance()->get_response(); $params = $request->get_parameters(); $brokerId = $request->getBrokerId(); $userId = $request->getUserId(); $cityId = $request->getBrokerCityId(); $brokerInfo = self::$BrokerInfo['BaseInfo']; //非套餐经纪人不能进入该页面,跳转到老账户页面 if ($brokerInfo['PAYTYPE'] != 9999) { $this->redirect($this->getURL('my', '/user/broker/accountmanagement/')); } $logtype = $params['logtype'] ? $params['logtype'] : ""; if (isset($params['p']) && !empty($params['p'])) { $page = intval($params['p']); } else { $page = 1; } if (empty($params['tt']) && empty($params['ff'])) { $starttime = date('Ymd', strtotime('-29 day')); $endtime = date('Ymd'); } else { $starttime = date("Ymd", strtotime($params['ff'])); $endtime = date("Ymd", strtotime($params['tt'])); } $AccountAll = 0; $dao = new Dao_Broker_AccountBalanceLog(); //通过 userid 获取账户日志 $UserAccountInfo = $dao->searchAccountBalanceLog($userId, $logtype, $starttime, $endtime, $page, $this->page_num); if (!empty($UserAccountInfo)) { $AccountAll = $UserAccountInfo['counts']; } unset($UserAccountInfo["counts"]); //echo "<pre>";print_r(isset($params['ff']) ? $params['ff'] : date('Y-m-d', strtotime($starttime)));exit; if (empty($UserAccountInfo) && empty($params['tt']) && empty($params['ff'])) { $starttime = date('Y-m-d', strtotime('-29 day')); $endtime = date('Y-m-d'); } $balance = Bll_Service_Payment::balance(Bll_Service_Payment::SITE_ANJUKE, array('userId' => $userId)); $FreezeAccount = $balance['data']['jp']['frozen'] / 100.0 + $balance['data']['hz']['frozen'] / 100.0 + $balance['data']['ajk']['frozen'] / 100.0; //冻结余额 $UserAccount = $balance['data']['balance'] / 100.0; //账户余额 $UserAccountPerson = $balance['data']['personBalance'] / 100.0; //账户余额(个人) $UserAccountCompany = $balance['data']['companyBalance'] / 100.0; //账户余额(公司) $UserAccountTotal = $FreezeAccount + $UserAccount; //账户总额 = 账户余额 + 冻结余额 //获取经纪人可以购买套餐列表 $companyId = $brokerInfo['COMPANYID']; $canBuyComboList = Bll_Combo_Broker_BrokerComboInfo::getCanBuyComboList($cityId, $companyId); //获取经纪人当前套餐 $brokerCombos = Bll_Combo_Broker_BrokerComboInfo::getBrokerComboAlreadyGroup($userId); $jinPuComingCombo = array(); $rentAndSaleComingCombo = array(); $allComboList = array(); foreach ($brokerCombos['nowCombo'] as $combo) { $comboTip = array('status' => 1, 'name' => $combo['name'], 'content' => $combo['comboStr'], 'beginDate' => date('Y.m.d', $combo['startTimestamp']), 'endDate' => date('Y.m.d', $combo['endTimestamp'])); $allComboList[] = $comboTip; } foreach ($brokerCombos['comingCombo'] as $combo) { $comboTip = array('status' => 0, 'name' => $combo['name'], 'content' => $combo['comboStr'], 'beginDate' => date('Y.m.d', $combo['startTimestamp']), 'endDate' => date('Y.m.d', $combo['endTimestamp'])); $allComboList[] = $comboTip; if (empty($rentAndSaleComingCombo) && ($combo['salePropNum'] > 0 || $combo['rentPropNum'])) { $rentAndSaleComingCombo = $combo; } if (empty($jinPuComingCombo) && $combo['jpPropNum'] > 0) { $rentAndSaleComingCombo = $combo; } } //金铺是否开放 $JinpuOpenConfig = APF::get_instance()->get_config("jinpu_open", "ppc"); $isJp = isset($JinpuOpenConfig[$cityId]) ? $JinpuOpenConfig[$cityId]['open'] : false; $request->set_attribute('isJp', $isJp); $request->set_attribute("AccountLogDownLOadName", sha1($userId . '安居客账户日志明细')); $request->set_attribute("UserAccount", number_format($UserAccount, 2, ".", "")); $request->set_attribute("UserAccountPerson", number_format($UserAccountPerson, 2, ".", "")); $request->set_attribute("UserAccountCompany", number_format($UserAccountCompany, 2, ".", "")); $request->set_attribute("FreezeAccount", number_format($FreezeAccount, 2, ".", "")); $request->set_attribute("UserAccountTotal", number_format($UserAccountTotal, 2, ".", "")); $request->set_attribute("UserAccountInfo", $UserAccountInfo); $request->set_attribute("AccountAll", $AccountAll); $request->set_attribute('params', $params); $request->set_attribute('ff', isset($params['ff']) ? $params['ff'] : date('Y-m-d', strtotime($starttime))); $request->set_attribute('tt', isset($params['tt']) ? $params['tt'] : date('Y-m-d', strtotime($endtime))); $arrPager = $this->getPager($params, $AccountAll); $request->set_attribute('arrPager', $arrPager); $request->set_attribute('canBuyComboList', $canBuyComboList); $request->set_attribute('brokerCombos', $brokerCombos); $request->set_attribute('allComboList', $allComboList); $request->set_attribute('rentAndSaleComingCombo', $rentAndSaleComingCombo); $request->set_attribute('jinPuComingCombo', $jinPuComingCombo); return 'Combo_Account_AccountLog'; }
public function handle_request_internal() { if (!$this->isBrokerLogin()) { $this->redirect_to_login(); } $request = APF::get_instance()->get_request(); $params = $request->get_parameters(); $userId = $request->getUserId(); $orderId = $params['orderId']; $sukId = $params['upDateComboName']; $orderName = $params['orderName']; $password = $params['brokerPassword']; $act = $params['act']; $brokerInfo = self::$BrokerInfo['BaseInfo']; //非套餐经纪人不能进入该页面,跳转到首页 if ($brokerInfo['PAYTYPE'] != 9999) { $this->redirect('/user/broker/brokerhome'); } //查询账户余额 $balance = Bll_Service_Payment::balance(Bll_Service_Payment::SITE_ANJUKE, array('userId' => $userId)); $UserAccountAll = $balance['data']['balance'] / 100.0; //账户余额 $UserAccountPerson = $balance['data']['personBalance'] / 100.0; //账户余额(个人) $UserAccountCompany = $balance['data']['companyBalance'] / 100.0; //账户余额(公司) //升级需要的金额 $result = Bll_Combo_Broker_BrokerComboInfo::getUpdatePrice($sukId, $orderId); //假数据 //$result['data'] = array('price' => 1000, 'startTime' => '2014-10-30 00:00:00.0', 'endTime' => '2014-12-30 00:00:00.0'); $errorInfo = ''; if ($result['result'] === false) { $errorInfo = '套餐升级api获取失败'; } if ($result['status'] == 'error') { $errorInfo = $result['info']; } if (!empty($errorInfo)) { $this->setAttribute('errorInfo', $errorInfo); } $buyComboInfo['price'] = round($result['data']['price'] / 100, 2); $buyComboInfo['startTime'] = date('Y.m.d', strtotime($result['data']['startTime'])); $buyComboInfo['endTime'] = date('Y.m.d', strtotime($result['data']['endTime'])); $buyComboInfo['day'] = floor((strtotime(date('Y-m-d', strtotime($result['data']['endTime']))) - strtotime(date('Y-m-d', strtotime($result['data']['startTime'])))) / 86400) + 1; $buyComboInfo['orderName'] = $orderName; if ($act != 'pay') { $str = ''; if ($params['AjkNum'] > 0) { $str .= '二手房' . $params['AjkNum'] . '套'; } if ($params['HzNum'] > 0) { $str .= ($str ? ',' : '') . '租房' . $params['HzNum'] . '套'; } if ($params['JpNum'] > 0) { $str .= ($str ? ',' : '') . '金铺' . $params['JpNum'] . '套'; } } else { $str = $params['NumStr']; } $buyComboInfo['propStr'] = $str; $buyComboInfo['sukId'] = $sukId; $buyComboInfo['orderId'] = $orderId; $buyComboInfo['AjkNum'] = $params['AjkNum']; $buyComboInfo['HzNum'] = $params['HzNum']; $buyComboInfo['JpNum'] = $params['JpNum']; $this->setAttribute('buyComboInfo', $buyComboInfo); $this->setAttribute('UserAccountAll', number_format($UserAccountAll, 2)); $request->set_attribute("UserAccountPerson", number_format($UserAccountPerson, 2)); $request->set_attribute("UserAccountCompany", number_format($UserAccountCompany, 2)); $this->setAttribute('params', $params); //购买 if ($act == 'pay') { //密码加密 $md5_password = md5($password); $baseencode_password = base64_encode($md5_password); //查询经纪人信息 $userInfo = Model_Broker_Member::getAjkMembersByUserId($userId); //验证密码 if ($userInfo->userPwd == $baseencode_password) { //升级 $buySuccess = Bll_Combo_Broker_BrokerComboInfo::upgradeCombo($userId, $sukId, $orderId); //升级是否成功 $this->setAttribute('buySuccess', $buySuccess['status']); $this->setAttribute('buyMessage', $buySuccess['errMsg']); return 'Combo_Update_Result'; } else { //密码错误 $this->setAttribute('pwdErr', 1); } } return 'Combo_Update_Pay'; }
/** * 获取经纪人的账户余额,单位:分 * * @param int $brokerId * @return int */ public static function getAccountBalance($brokerId) { $userId = Bll_Broker_MainBusiness::getDataByEsfId($brokerId)->memberId; /** * @var $balanceInfo Bll_Service_Client_HttpResponse */ $balanceInfo = Bll_Service_Payment::balance(Bll_Service_Payment::SITE_ANJUKE, array('userId' => $userId)); if (!$balanceInfo->isSucceeded()) { return -1; } if ($balanceInfo['status'] == 'error') { return -1; } return $balanceInfo['data']['balance']; }
/** * 安比购买抢客劵 * @param $broker * @param $coupon * @param $amount * @param $payType * @param $source * @return array() */ public function buyCouponByAnbi($broker, $coupon, $amount, $payType, $source) { $result = array('status' => 'error', 'msg' => '', 'order' => ''); $brokerId = $broker['brokerId']; //查询账户余额是否足够 $balance = Bll_Service_Payment::balance(Bll_Service_Payment::SITE_ANJUKE, array('userId' => $broker['userId'])); if (empty($balance) || $balance['status'] != 'ok') { $result['msg'] = '查询余额失败,稍后再试'; return $result; } $userAccountAll = $balance['data']['balance']; //账户余额 $needAccount = $coupon['disPrice'] * $amount; // 待扣费金额 if ($userAccountAll < $needAccount || $needAccount < 0) { $result['msg'] = '余额不足,请充值'; return $result; } // 创建订单 $order = Bll_CustomerRush_Order::getInstance()->createOrder($brokerId, "", $coupon, $amount, $payType, $source); //$requestId = Bll_Customerrush_Payment_Common::getInstance()->createRequsetId("charge",$order['id']); $requestId = Bll_Customerrush_Payment_Common::getInstance()->createChargeRequsetId($order['orderNo']); $order->msg = json_encode(array("requestId" => $requestId)); // 保存requestId; $order->updateTime = date("Y-m-d H:i:s"); $order->save(); // 调用扣费接口 $cusumeResult = Bll_Customerrush_Payment_Common::getInstance()->chargeMoneyByAnbi($brokerId, $broker['userId'], $requestId, $needAccount); if ($cusumeResult['status'] != 'ok') { $result['msg'] = '扣费失败,请稍后再试。'; return $result; } // 记录扣费日志 $log2 = array('brokerId' => $brokerId, 'accountId' => 0, 'price' => $needAccount, 'realPrice' => $needAccount, 'amount' => 0, 'requestId' => $requestId, 'type' => 2, 'createTime' => time()); Bll_CustomerRush_Payment_Log::getInstance()->insertBrokerBalanceLog($log2); // 更新订单 $order->status = Model_Mobile_CustomerOrder::STATUS_OK; $order->msg = json_encode(array("payInfo" => "success", "requestId" => $requestId)); $order->updateTime = date("Y-m-d H:i:s"); $order->save(); // 给经纪人加劵 for ($i = 0; $i < $order->num; $i++) { $addCoupon = array('brokerId' => $brokerId, 'couponId' => $order['couponId'], 'status' => Model_Mobile_CustomerBrokerCoupon::STATUS_OK_USE, 'totalNum' => $coupon['totalNum'], 'usedNum' => 0, 'updateTime' => date("Y-m-d H:i:s"), 'createTime' => time(), 'orderId' => $order['id']); Bll_CustomerRush_Coupon::getInstance()->insertBrokerCoupon($addCoupon); } $result['status'] = 'ok'; $result['order'] = $order; return $result; }
public function updateCheck($orderId, $upSkuId, $userId, $checkState) { if (empty($orderId) || empty($upSkuId)) { return array('status' => 'error', 'errMsg' => '请选择升级的套餐'); } //判定经纪人审核状态 if ($checkState != 1) { return array('status' => 'error', 'errMsg' => '双证审核未通过,不能购买套餐'); } $result = Bll_Combo_Broker_BrokerComboInfo::getUpdatePrice($upSkuId, $orderId); if (empty($result) || $result['result'] === false) { return array('status' => 'err', 'errMsg' => '套餐升级api获取失败'); } if ($result['status'] == 'error') { return array('status' => 'err', 'errMsg' => $result['info']); } //假数据 //$result['data'] = array('price' => 1000, 'startTime' => '2014-12-30 00:00:00.0', 'endTime' => '2014-12-30 00:00:00.0'); //判定账户余额 $balance = Bll_Service_Payment::balance(Bll_Service_Payment::SITE_ANJUKE, array('userId' => $userId)); $balancePerson = $balance['data']['personBalance']; //账户余额(个人) if ($balancePerson < $result['data']['price']) { return array('status' => 'err', 'errMsg' => '可用余额不足,<a href="/user/broker/hpsupplement">请充值</a>', 'price' => round($result['data']['price'] / 100, 2), 'frome' => date('Y.m.d', strtotime($result['data']['startTime'])), 'to' => date('Y.m.d', strtotime($result['data']['endTime']))); } $re = array(); $re['status'] = 'ok'; if ($result['data']) { $re['price'] = round($result['data']['price'] / 100, 2); $re['frome'] = date('Y.m.d', strtotime($result['data']['startTime'])); $re['to'] = date('Y.m.d', strtotime($result['data']['endTime'])); } return $re; }
public function handle_request_internal() { if (!$this->isBrokerLogin()) { $this->redirect_to_login(); } /** * @var $request AJKRequest */ $request = APF::get_instance()->get_request(); $objResponse = APF::get_instance()->get_response(); $params = $request->get_parameters(); $brokerId = $request->getBrokerId(); $cityId = $request->getBrokerCityId(); $userId = $request->getUserId(); $sukId = $params['combo']; $password = $params['brokerPassword']; $act = $params['act']; $brokerInfo = self::$BrokerInfo['BaseInfo']; //非套餐经纪人不能进入该页面,跳转到首页 if ($brokerInfo['PAYTYPE'] != 9999) { $this->redirect('/user/broker/brokerhome'); } //查询账户余额 $balance = Bll_Service_Payment::balance(Bll_Service_Payment::SITE_ANJUKE, array('userId' => $userId)); $UserAccountAll = $balance['data']['balance'] / 100.0; //账户余额 $UserAccountPerson = $balance['data']['personBalance'] / 100.0; //账户余额(个人) $UserAccountCompany = $balance['data']['companyBalance'] / 100.0; //账户余额(公司) $companyId = intval($brokerInfo['COMPANYID']); if ($companyId > 0) { /** 通过配置文件配置那些城市的非独立经纪人不可以购买月套餐 */ $canNotBuyMonthlyComboCitySet = APF::get_instance()->get_config('can_not_buy_monthly_combo_city_set'); if (is_array($canNotBuyMonthlyComboCitySet) && in_array($cityId, $canNotBuyMonthlyComboCitySet)) { $companyId = 0; } } //经纪人能否购买 $buyComboInfo = Bll_Combo_Broker_BrokerComboInfo::getBrokerallowBuy($brokerId, $cityId, $sukId, $companyId); $this->setAttribute('buyComboInfo', $buyComboInfo); $this->setAttribute('UserAccountAll', number_format($UserAccountAll, 2)); $request->set_attribute("UserAccountPerson", number_format($UserAccountPerson, 2)); $request->set_attribute("UserAccountCompany", number_format($UserAccountCompany, 2)); $this->setAttribute('params', $params); //看能不能购买 if (!$buyComboInfo['allowBuy']) { return 'Combo_Buy_Result'; } //购买 if ($act == 'pay') { //密码加密 $md5_password = md5($password); $baseencode_password = base64_encode($md5_password); //查询经纪人信息 $userInfo = Model_Broker_Member::getAjkMembersByUserId($userId); //验证密码 if ($userInfo->userPwd == $baseencode_password) { //购买 $buySuccess = Bll_Combo_Broker_BrokerComboInfo::buyCombo($userId, $sukId); //购买是否成功 $this->setAttribute('buySuccess', $buySuccess); return 'Combo_Buy_Result'; } else { //密码错误 $this->setAttribute('pwdErr', 1); } } return 'Combo_Buy_Pay'; }
/** * 调用扣费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; }
/** * 扣费 * @param $userId * @param $price * @param string $userAccountId * @param $note * @param $requestId * @return array */ public function chargeMoney($userId, $price, $userAccountId = "", $note, $requestId) { $result = array('status' => false, 'balance' => 0, 'msg' => ''); if (empty($userId) || empty($price) || empty($note) || empty($requestId)) { $result['msg'] = "参数不正确"; 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, 'requestid' => $requestId, 'amount' => $price, 'note' => $note, 'addnote' => ""); $configPayment = Const_PaymentApp::FYK; $apiResult = Bll_Service_Payment::pay($configPayment, $params); if ($apiResult->isSucceeded()) { $transferInfo = $apiResult->getTransferInfo(); if ($apiResult['result'] == true) { $result['status'] = true; $result['balance'] = $apiResult['amount']; $result['msg'] = array('response' => $apiResult->getResponse(), 'transferInfo' => array('url' => $transferInfo['url'], 'content_type' => $transferInfo['content_type'], 'http_code' => $transferInfo['http_code'])); break; } else { $result['msg'] = 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('userId' => $userId, 'accountId' => $accountId, 'price' => $price, 'amount' => $result['balance'], 'requestId' => $requestId, 'status' => $result['status'] ? 2 : 1, 'msg' => json_encode($apiResult), 'createTime' => time()); Bll_Fyk_Payment_Log::getInstance()->insertPayRequestLog($addLogArr); return $result; }
/** * 精选房源冻结 * * @param $ajk_broker_id * @param $amount * @param $reqId * @param $note * @param $site * @return Bll_Service_Client_HttpResponse */ public static function bid_freeze($ajk_broker_id, $amount, $reqId, $note, $site) { $userId = Bll_Broker_MainBusiness::getDataByEsfId($ajk_broker_id)->memberId; $bidInfo = Bll_Service_Payment::bidFreeze($site, array('userId' => $userId, 'amount' => $amount, 'reqId' => $reqId, 'note' => $note)); return $bidInfo; }
/** * 开启精选计划 * * @param $brokerId int 经纪人id * @param $propId int 房源id * @param $budget int 预算,单位元 */ public function startChoice($brokerId, $propId, $budget) { try { //获取经纪人基本信息 $brokerBaseInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId); if (empty($brokerBaseInfo)) { $this->error(self::EMPTY_BROKER_ERROR, self::EMPTY_BROKER_ERROR_MSG); } $cityId = $brokerBaseInfo->cityId; $userId = $brokerBaseInfo->userId; //判断经纪人城市是否开通精选 if (!$this->checkChoiceOpen($brokerBaseInfo->cityId)) { $this->error(self::CHOICE_CLOSE_ERROR, self::CHOICE_CLOSE_ERROR_MSG); } //判断预算的合法性 if ($budget < Bll_Plan_Bid_Choice::ESF_CHOICE_MIN_BUDGET || $budget > Bll_Plan_Bid_Choice::ESF_CHOICE_MAX_BUDGET) { $this->error(self::BUDGET_INVALID_ERROR, self::BUDGET_INVALID_ERROR_MSG); } //判断余额是否足够 $balanceResponse = Bll_Service_Payment::balance(Bll_Service_Payment::SITE_ANJUKE, array('userId' => $brokerBaseInfo->userId)); if ($balanceResponse['status'] == 'error') { throw new Exception(self::SYSTEM_BUSY_ERROR, self::SYSTEM_BUSY_ERROR_MSG); } $balance = $balanceResponse['data']['balance']; if ($balance / 100 < $budget) { $this->error(self::BANANCE_LESS_BUDGET, self::BANANCE_LESS_BUDGET_MSG); } //获取房源信息 $houseInfo = Bll_House_EsfHouse::getHouseBaseInfo($propId, $cityId); if (empty($houseInfo)) { $this->error(self::PROP_NOT_EXIST_ERROR, self::PROP_NOT_EXIST_ERROR_MSG); } $houseInfo = $houseInfo[0]; //操作人验证 if ($houseInfo->userId != $userId) { $this->error(self::PROP_OPREATE_ACCESS_INVALID_ERROR, self::PROP_OPREATE_ACCESS_INVALID_ERROR_MSG); } //房源是否可以精选验证 if ($houseInfo->isVisible != 1) { //违规验证 $this->error(self::PROP_CHOICE_NOT_FIT_ISVISIBLE_ERROR, self::PROP_CHOICE_NOT_FIT_ISVISIBLE_ERROR_MSG); } if ($houseInfo->isHighQulity == 0) { //多图验证 $this->error(self::PROP_CHOICE_NOT_FIT_ISHIGHQULITY_ERROR, self::PROP_CHOICE_NOT_FIT_ISHIGHQULITY_ERROR_MSG); } if (date('Ymd', strtotime('-16 days')) > date('Ymd', $houseInfo->postDate)) { //发布时间验证 $this->error(self::PROP_CHOICE_NOT_FIT_POSTDATE_ERROR, self::PROP_CHOICE_NOT_FIT_POSTDATE_ERROR_MSG); } $planInfo = Model_Plan_EsfAjkPropSpread::getChoicePlanInfoByHouseid($propId); if (!empty($planInfo)) { $reBid = 1; } //判断当前经纪人已经精选推广的房源数 if ($reBid) { if (Bll_Plan_Bid_Choice::checkEsfBidChoiceFull($brokerId, $cityId, 1)) { $this->error(self::MAX_CHOICE_NUM_ERROR, sprintf(self::MAX_CHOICE_NUM_ERROR_MSG, Bll_Plan_Bid_Choice::$all_esf_plan_num)); } } else { if (Bll_Plan_Bid_Choice::checkEsfBidChoiceFull($brokerId, $cityId)) { $this->error(self::MAX_CHOICE_NUM_ERROR, sprintf(self::MAX_CHOICE_NUM_ERROR_MSG, Bll_Plan_Bid_Choice::$all_esf_plan_num)); } } //套餐经纪人 还是ppc经纪人 /*$IsComboCity = Bll_Broker_HzBroker::isComboBroker($brokerId); if ($IsComboCity) { //是否套餐推广 $comboHouseRelation = Model_Combo_HouseRelation::getOnlineHousebyHouseId($brokerId, $propId, $cityId, Model_Combo_HouseRelation::SITE_TYPE_AJK); if(empty($comboHouseRelation)) { $this->error(self::PROP_NO_COMBO, self::PROP_NO_COMBO_MSG); } } else { //判断房源的定价计划状态 $fixPlanBll = new Bll_FixedSpread_PropFixedPlanRelation(); $fixPlanRelationStatus = $fixPlanBll->getProSpreadRelationByProId($propId, $cityId); if ($fixPlanRelationStatus['Status'] != 1) { $this->error(self::PROP_CHOICE_NOT_FIT_FIXED_ERROR, self::PROP_CHOICE_NOT_FIT_FIXED_ERROR_MSG); } }*/ /** 判断是否是精选开放城市 */ if (!Bll_City::isChoiceIndependentCity($cityId, Const_Site::ANJUKE)) { /** 判断是在套餐推广中 */ $houseState = Bll_Combo_HouseRelation::getOnlineRelationByHouseId($propId, Bll_Combo_HouseRelation::SITE_TYPE_AJK); if (empty($houseState)) { $this->error(self::PROP_NO_COMBO, self::PROP_NO_COMBO_MSG); } } /** 防并发 */ if (false === Bll_Plan_Bid_Choice::rejectSameRequest(Bll_Plan_Bid_Choice::SITE_AJK, $brokerId, $propId)) { $this->error(self::OPERATION_TIME_ERROR, self::OPERATION_TIME_ERROR_MSG); } //判断是否已在竞价计划中 if ($reBid) { if ($planInfo->status == Model_Plan_EsfAjkPropSpread::ONLINE || $planInfo->status == Model_Plan_EsfAjkPropSpread::ONQUEUE) { $this->error(self::PROP_CHOICE_NOT_FIT_CHOICED_ERROR, self::PROP_CHOICE_NOT_FIT_CHOICED_ERROR_MSG); } } else { if (!empty($planInfo) || $planInfo->status == Model_Plan_EsfAjkPropSpread::ONLINE || $planInfo->status == Model_Plan_EsfAjkPropSpread::ONQUEUE) { $this->error(self::PROP_CHOICE_NOT_FIT_CHOICED_ERROR, self::PROP_CHOICE_NOT_FIT_CHOICED_ERROR_MSG); } } //重新推广,判断结算状态 if ($reBid) { if ($planInfo->tradestatus != Model_Plan_EsfAjkPropSpread::COMPLETETTRADESTATU) { $this->error(self::PROP_CHOICE_NOT_SETTLE_ERROR, self::PROP_CHOICE_NOT_SETTLE_ERROR_MSG); } } $housePrice = intval($houseInfo->proPrice * 10000); $priceIntervalInfo = Model_House_EsfPrice::get_price($cityId, $housePrice); if (empty($priceIntervalInfo)) { $this->error(self::PROP_PRICE_UNKNOW_ERROR, self::PROP_PRICE_UNKNOW_ERROR_MSG); } $priceId = $priceIntervalInfo['id']; $minPrice = $priceIntervalInfo['minPrice']; $maxPrice = $priceIntervalInfo['maxPrice']; //查询坑情况 $bucketInfo = Model_Choice_EsfBidBucket::get_bucket_info($houseInfo->commId, $priceId); if (empty($bucketInfo)) { if (Model_Choice_EsfBidBucket::init_bucket_info($houseInfo->commId, $priceId, $cityId)) { $bucketInfo = array('communityId' => $houseInfo->commId, 'priceId' => $priceId, 'totalNum' => Model_Choice_EsfBidBucket::TOTALNUM, 'usedNum' => 0, 'maxOnlineNum' => Model_Choice_EsfBidBucket::MAXONLINENUM); } else { $this->error(self::SYSTEM_BUSY_ERROR, self::SYSTEM_BUSY_ERROR_MSG); } } //预判断坑位 if ($bucketInfo['usedNum'] >= $bucketInfo['totalNum']) { $this->error(self::CHOICE_QUEUE_FULL, self::CHOICE_QUEUE_FULL_MSG); } //按照最大坑位数目更新 if (!Model_Choice_EsfBidBucket::increment_used_num($houseInfo->commId, $priceId, 0)) { $this->error(self::SYSTEM_BUSY_ERROR, self::SYSTEM_BUSY_ERROR_MSG); } //获取reuqestid $year = date('Y'); $bll = new Bll_Plan_BidFreezeOrderNum($year); $requestId = $bll->getRequestId(Bll_Plan_BidFreezeOrderNum::ESF, $userId, $year, 0, $propId); //冻结金额 $amount = $budget * 100; $note = sprintf("二手房精选房源冻结,propId: %d", $propId); if (($freezeResult = Bll_Plan_Bid_Choice::bid_freeze($brokerId, $amount, $requestId, $note, Const_PaymentApp::AJK_CHOICE)) === false) { $this->error(self::SYSTEM_BUSY_ERROR, self::SYSTEM_BUSY_ERROR_MSG); } if (!$freezeResult->isSucceeded()) { $this->error(self::SYSTEM_BUSY_ERROR, self::SYSTEM_BUSY_ERROR_MSG); } if ($freezeResult['status'] == 'error') { $this->error(self::CHOICE_FREEZE_ERROR, self::CHOICE_FREEZE_ERROR_MSG); } $snNum = $freezeResult['data']['sn']; //重新推广,将原来的推广计划置为删除状态 if ($reBid) { $planInfo->status = Model_Plan_EsfAjkPropSpread::DELETE; if (!$planInfo->save()) { $this->error(self::SYSTEM_BUSY_ERROR, self::SYSTEM_BUSY_ERROR_MSG); } } for ($i = 0; $i < 3; $i++) { //价格 $clickPrice = Bll_Service_Choice::ajkClickPrice(array('brokerId' => $brokerId, 'cityId' => $cityId, 'price' => $housePrice, 'commId' => $houseInfo->commId)); if ($clickPrice->isSucceeded()) { break; } } if (empty($clickPrice) || $clickPrice['status'] != 'ok') { $this->error(self::SYSTEM_BUSY_ERROR, self::SYSTEM_BUSY_ERROR_MSG); } $priceUnit = round($clickPrice['realTradeAmount'] / 100, 2); //新建计划 $time = time(); $offer = $priceUnit * 100; $stopTime = $time + Bll_Plan_Bid_Choice::ESF_AUTO_STOP_TIME; $endTime = time() + Model_Plan_EsfAjkPropSpread::CHOICELASTINGTIME; $arrAddInfo['serialnumber'] = $snNum; $arrAddInfo['propId'] = $propId; $arrAddInfo['cityId'] = $cityId; $arrAddInfo['commId'] = $houseInfo->commId; $arrAddInfo['brokerId'] = $brokerId; $arrAddInfo['userId'] = $userId; $arrAddInfo['budget'] = $amount; $arrAddInfo['balance'] = $amount; $arrAddInfo['spreadstartdate'] = $time; $arrAddInfo['spreadenddate'] = $endTime; $arrAddInfo['bigprice'] = $maxPrice; $arrAddInfo['smallprice'] = $minPrice; $arrAddInfo['propriceint'] = $housePrice; $arrAddInfo['status'] = Model_Plan_EsfAjkPropSpread::ONQUEUE; $arrAddInfo['isreserve'] = Model_Plan_EsfAjkPropSpread::RESERVE; $arrAddInfo['bidVersion'] = Model_Plan_EsfAjkPropSpread::CHOICEVERSION; $arrAddInfo['areacode'] = $houseInfo->areaCode; $arrAddInfo['stoptime'] = $stopTime; $arrAddInfo['createtime'] = $time; $arrAddInfo['offer'] = $offer; //排名系数,请直接绕过 +_+ $hpratioABll = new Bll_Plan_Bid_EsfHpratioA(); $arrAddInfo['qulityScore'] = $hpratioABll->getHouseMass($propId, $brokerId, $cityId, $houseInfo->commId, $houseInfo->hasRoomPic, $houseInfo->isHighQulity, $houseInfo->postDate, $houseInfo->unitPrice); $commScore = round($hpratioABll->getCommScore($houseInfo->commId), 5); $arrAddInfo['commScore'] = $commScore; $userActionScore = $hpratioABll->getUserActionScore($propId, $cityId); $arrAddInfo['behaviorScore'] = $userActionScore; $arrAddInfo['hpratioA'] = $hpratioABll->getHpraio($offer, $arrAddInfo['qulityScore'], $userActionScore); $hpratioNorm = $hpratioABll->getPpcNormHpratio($arrAddInfo['hpratioA'], $houseInfo->commId, false, $minPrice, $maxPrice, $houseInfo->areaCode); $arrAddInfo['commsHpratioA'] = round($commScore * $hpratioNorm, 5); if (($planId = Model_Plan_EsfAjkPropSpread::insertLayer($arrAddInfo)) === false) { $this->error(self::SYSTEM_BUSY_ERROR, self::SYSTEM_BUSY_ERROR_MSG); } //新精选队列插入记录 if (!Bll_Plan_Bid_EsfChoiceQueue::insert($brokerId, $planId, Model_Choice_ActionQueue::ENUM_BEGIN_BY_HAND, date('m'), $brokerId, '经纪人手动开始推广', APF::get_instance()->get_request()->get_client_ip())) { $this->error(self::SYSTEM_BUSY_ERROR, self::SYSTEM_BUSY_ERROR_MSG); } //插入自动停止队列 $stopType = Model_Plan_EsfAjkPropspreadQueue::AUTOSTOP; Model_Plan_EsfAjkPropspreadQueue::insertOne($planId, $stopTime, $stopType); //记录log表 $remark = sprintf("PROP_ID:null=>%d;CITY_ID:null=>%d;COMM_ID:null=>%d;BROKER_ID:null=>%d;USER_ID:null=>%d;BUDGET:null=>%d;SPREADSTARTDATE:null=>%d;SPREADENDDATE:null=>%d;STATUS:null=>%d;ISRESERVE:null=>%d;SERIALNUMBER:null=>%d;TRADETYPE:0=>1;BALANCE:0=>%d;PROPRICEINT:0=>%d;BIGPRICE:0=>%d;SMALLPRICE:0=>%d", $propId, $cityId, $houseInfo->commId, $brokerId, $userId, $amount, $time, $endTime, Model_Plan_EsfAjkPropSpread::ONQUEUE, Model_Plan_EsfAjkPropSpread::RESERVE, $snNum, $amount, $housePrice, $maxPrice, $minPrice); Model_Plan_LogAjkPropspread::addNewLog($planId, $brokerId, Model_Plan_LogAjkPropspread::ADD, $remark); //更新reuqest id完成 if (!$bll->updateRequestComplete($requestId)) { $this->error(self::SYSTEM_BUSY_ERROR, self::SYSTEM_BUSY_ERROR_MSG); } $rankNum = Bll_Plan_Bid_Choice::getEsfOnlineAndOnQueueNum($planId, $houseInfo->commId, $minPrice, $maxPrice); if ($rankNum <= $bucketInfo['maxOnlineNum']) { return array('status' => self::START_CHOICE_TO_ONLINE, 'statusMsg' => self::START_CHOICE_TO_ONLINE_MSG); } else { return array('status' => self::START_CHOICE_TO_ONQUEUE, 'statusMsg' => self::START_CHOICE_TO_ONQUEUE_MSG); } } catch (Exception $e) { if ($e instanceof Exception_BllErrorException) { $this->errorCode = $e->getCode(); } else { $this->errorCode = self::UNKNOW_ERROR; } $this->errorMsg = $e->getMessage(); return false; } }
public function getAckValue($accountId) { $result = array('status' => false, 'sessionkey' => '', 'msg' => ''); if (empty($accountId)) { $result['msg'] = "参数不正确"; return $result; } $count = 0; while (true) { if ($count >= 3) { break; } // 调用api,开始扣钱 $params = array('account' => $accountId, "action" => "getkey"); $configPayment = Const_PaymentApp::FYK; $apiResult = Bll_Service_Payment::ack($configPayment, $params); if ($apiResult->isSucceeded()) { if ($apiResult['sessionkey']) { $result['status'] = true; $result['sessionkey'] = $apiResult['sessionkey']; break; } else { $count++; } $result['msg'] = '链接失败'; $count++; } } return $result; }
public function handle_request_internal() { $apf = APF::get_instance(); $request = $apf->get_request(); $response = $apf->get_response(); if ($this->get_broker_usertype() != 2) { //普通用户不能进入此页面 $this->redirect_to_login(); } $params = $request->get_parameters(); $broker = self::$BrokerInfo; //套餐经纪人,进入新的账户管理页面 if ($broker['BaseInfo']['PAYTYPE'] == 9999) { $this->redirect('/ajkbroker/combo/account/accountlog'); } $logtype = $params['logtype'] ? $params['logtype'] : ""; if (isset($params['p']) && !empty($params['p'])) { $page = intval($params['p']); } else { $page = 1; } $userId = $broker['BaseInfo']['USERID']; if (empty($params['tt']) && empty($params['ff'])) { $lastDay = Model_Log_AccountBalanceLog::getLastDayByUserId($broker['BaseInfo']['USERID']); $starttime = $lastDay; $endtime = $lastDay; } else { $starttime = date("Ymd", strtotime($params['ff'])); $endtime = date("Ymd", strtotime($params['tt'])); } $AccountAll = 0; $dao = new Dao_Broker_AccountBalanceLog(); //通过 userid 获取账户日志 $UserAccountInfo = $dao->searchAccountBalanceLog($userId, $logtype, $starttime, $endtime, $page, $this->page_num); if (!empty($UserAccountInfo)) { $AccountAll = $UserAccountInfo['counts']; } unset($UserAccountInfo["counts"]); //echo "<pre>";print_r(isset($params['ff']) ? $params['ff'] : date('Y-m-d', strtotime($starttime)));exit; if (empty($UserAccountInfo) && empty($params['tt']) && empty($params['ff'])) { $starttime = date('Y-m-d', strtotime('-29 day')); $endtime = date('Y-m-d'); } $balance = Bll_Service_Payment::balance(Bll_Service_Payment::SITE_ANJUKE, array('userId' => $userId)); $FreezeAccount = $balance['data']['jp']['frozen'] / 100.0 + $balance['data']['hz']['frozen'] / 100.0 + $balance['data']['ajk']['frozen'] / 100.0; //冻结余额 $UserAccount = $balance['data']['balance'] / 100.0; //账户余额 $UserAccountTotal = $FreezeAccount + $UserAccount; //账户总额 = 账户余额 + 冻结余额 $request->set_attribute("AccountLogDownLOadName", sha1($broker['BaseInfo']['USERID'] . '安居客账户日志明细')); $request->set_attribute("UserAccount", $UserAccount); $request->set_attribute("FreezeAccount", $FreezeAccount); $request->set_attribute("UserAccountTotal", $UserAccountTotal); $request->set_attribute("UserAccountInfo", $UserAccountInfo); $request->set_attribute("AccountAll", $AccountAll); $request->set_attribute('params', $params); $request->set_attribute('ff', isset($params['ff']) ? $params['ff'] : date('Y-m-d', strtotime($starttime))); $request->set_attribute('tt', isset($params['tt']) ? $params['tt'] : date('Y-m-d', strtotime($endtime))); $arrPager = $this->getPager($params, $AccountAll); $request->set_attribute('arrPager', $arrPager); return 'Broker_Accountmanagement'; }
public function handle_request() { $refundClickList = Model_Stats_JpBlackVppv::scanByClickDt($this->_startId, $this->_date, self::BATCH_LIMIT); foreach ($refundClickList as $refundClick) { $this->setFlag(array('id' => $refundClick['id'])); $this->setLogContentPrefix($refundClick['id']); $this->setLog(sprintf('点击信息:%s', json_encode($refundClick))); $chargeLog = Model_Log_JpCharge::getRowById($refundClick['id']); if (empty($chargeLog)) { $this->setLog('没有获取到点击的扣费信息'); continue; } $this->setLog(sprintf('扣费信息: %s', json_encode($chargeLog))); if (Model_Log_JpCharge::CHARGE_TYPE_0 != $chargeLog[Model_Log_JpCharge::CHARGE_TYPE]) { $this->setLog('不是扣费记录'); continue; } if ($chargeLog['spread_type'] != Model_Log_JpCharge::SPREAD_TYPE_2) { $this->setLog('非精选扣费'); continue; } if ($chargeLog['is_refund'] != Model_Log_JpCharge::IS_REFUND_0) { $this->setLog('已经退费过了'); continue; } /** 执行退费逻辑 调用 Java API */ $jpMemberInfo = Model_Broker_JpBroker::getBrokerInfoById($refundClick['memberId'], array('ajkMemberId', 'id', 'isDelete', 'source')); if (empty($jpMemberInfo)) { $this->setLog(sprintf('没有获取到用户[%d]的信息', $refundClick['memberId'])); continue; } $this->setLog(sprintf('用户[%d]的信息: %s', $refundClick['memberId'], json_encode($jpMemberInfo))); $ajkUserId = Model_Broker_AjkBrokerExtend::getUserIdByBrokerId($jpMemberInfo['ajkMemberId']); if ($ajkUserId == 0) { $this->setLog(sprintf('没有获取到用户[jp:%d ajk:%d]的user id', $refundClick['memberId'], $jpMemberInfo['ajkMemberId'])); continue; } $this->setLog(sprintf('用户[jp:%d ajk:%d]的userId=%d', $refundClick['memberId'], $jpMemberInfo['ajkMemberId'], $ajkUserId)); $params = array('reqId' => $refundClick['id'], 'userId' => $ajkUserId, 'amount' => $chargeLog['real_cost'], 'note' => sprintf('房源[%d]精选点击退费', $refundClick['proId'])); $this->setLog(sprintf('请求的参数:%s', http_build_query($params))); $refundSuccess = false; for ($i = 0; $i < 3; $i++) { /** * @var Bll_Service_Client_HttpResponse $apiResponse */ $apiResponse = Bll_Service_Payment::refund(Const_PaymentApp::JP_SITE, $params); $this->setLog(sprintf('调用API退费返回值:%s', json_encode($apiResponse->getResponse()))); if ($apiResponse->isSucceeded() && isset($apiResponse['result']) && $apiResponse['result'] == true) { $refundSuccess = true; break; } } if ($refundSuccess == false) { $this->setLog('调用API退费失败'); continue; } /** 更新扣费日志状态 */ if (false == Model_Log_JpCharge::refund($chargeLog['id'])) { $this->setLog(sprintf('[%d] 修改表 Model_Log_JpCharge.is_refund 失败', $chargeLog['id'])); } else { $this->setLog(sprintf('[%d] 修改表 Model_Log_JpCharge.is_refund 成功', $chargeLog['id'])); } } if (count($refundClickList) < self::BATCH_LIMIT) { $this->removeFlag(); $this->setShStopFlag(); $this->setLog('处理完成...'); } }
public function handle_request_internal() { if (!$this->isBrokerLogin()) { $this->redirect_to_login(); } $apf = APF::get_instance(); $request = APF::get_instance()->get_request(); $objResponse = APF::get_instance()->get_response(); $params = $request->get_parameters(); $brokerId = $request->getBrokerId(); $userId = $request->getUserId(); $cityId = $request->getBrokerCityId(); $brokerInfo = self::$BrokerInfo['BaseInfo']; //非套餐经纪人不能进入该页面,跳转到首页 if ($brokerInfo['PAYTYPE'] != 9999) { $this->redirect('/user/broker/brokerhome'); } if (isset($params['p']) && !empty($params['p'])) { $page = intval($params['p']); } else { $page = 1; } //获取经纪人日志的总数 $comboLogNum = Bll_Combo_Broker_BrokerComboInfo::getComboLogNumByUserId($userId); //查询列表数据 $ComboLogList = Bll_Combo_Broker_BrokerComboInfo::getComboLogListByUserId($userId, $page, $this->page_num); //分页参数获取 $arrPager = $this->getPager($params, $comboLogNum); //获取经纪人可以购买套餐列表 $companyId = $brokerInfo['COMPANYID']; $canBuyComboList = Bll_Combo_Broker_BrokerComboInfo::getCanBuyComboList($cityId, $companyId); //获取经纪人当前套餐 $brokerCombos = Bll_Combo_Broker_BrokerComboInfo::getBrokerComboAlreadyGroup($userId); $allComboList = array(); foreach ($brokerCombos['nowCombo'] as $combo) { $comboTip = array('status' => 1, 'name' => $combo['name'], 'content' => $combo['comboStr'], 'beginDate' => date('Y.m.d', $combo['startTimestamp']), 'endDate' => date('Y.m.d', $combo['endTimestamp'])); $allComboList[] = $comboTip; } $jinPuComingCombo = array(); $rentAndSaleComingCombo = array(); foreach ($brokerCombos['comingCombo'] as $combo) { $comboTip = array('status' => 0, 'name' => $combo['name'], 'content' => $combo['comboStr'], 'beginDate' => date('Y.m.d', $combo['startTimestamp']), 'endDate' => date('Y.m.d', $combo['endTimestamp'])); $allComboList[] = $comboTip; if (empty($rentAndSaleComingCombo) && ($combo['salePropNum'] > 0 || $combo['rentPropNum'])) { $rentAndSaleComingCombo = $combo; } if (empty($jinPuComingCombo) && $combo['jpPropNum'] > 0) { $rentAndSaleComingCombo = $combo; } } //查询账户情况 $balance = Bll_Service_Payment::balance(Bll_Service_Payment::SITE_ANJUKE, array('userId' => $userId)); $FreezeAccount = $balance['data']['jp']['frozen'] / 100.0 + $balance['data']['hz']['frozen'] / 100.0 + $balance['data']['ajk']['frozen'] / 100.0; //冻结余额 $UserAccount = $balance['data']['balance'] / 100.0; //账户余额 $UserAccountPerson = $balance['data']['personBalance'] / 100.0; //账户余额(个人) $UserAccountCompany = $balance['data']['companyBalance'] / 100.0; //账户余额(公司) $UserAccountTotal = $FreezeAccount + $UserAccount; //账户总额 = 账户余额 + 冻结余额 //金铺是否开放 $JinpuOpenConfig = APF::get_instance()->get_config("jinpu_open", "ppc"); $isJp = isset($JinpuOpenConfig[$cityId]) ? $JinpuOpenConfig[$cityId]['open'] : false; $request->set_attribute('arrPager', $arrPager); $request->set_attribute('isJp', $isJp); $request->set_attribute('canBuyComboList', $canBuyComboList); $request->set_attribute('brokerCombos', $brokerCombos); $request->set_attribute('allComboList', $allComboList); $request->set_attribute('ComboLogList', $ComboLogList); $request->set_attribute("UserAccount", number_format($UserAccount, 2, ".", "")); $request->set_attribute("UserAccountPerson", number_format($UserAccountPerson, 2, ".", "")); $request->set_attribute("UserAccountCompany", number_format($UserAccountCompany, 2, ".", "")); $request->set_attribute("FreezeAccount", number_format($FreezeAccount, 2, ".", "")); $request->set_attribute("UserAccountTotal", number_format($UserAccountTotal, 2, ".", "")); $request->set_attribute('rentAndSaleComingCombo', $rentAndSaleComingCombo); $request->set_attribute('jinPuComingCombo', $jinPuComingCombo); return 'Combo_Account_ComboLog'; }
public function getMemberBalance($memberId) { $memberInfo = Model_Broker_JpBroker::data_access()->filter('id', $memberId)->get_row(); if (intval($memberInfo['ajkMemberId']) > 0) { $ajkBrokerInfo = Model_Broker_AjkBrokerExtend::data_access()->filter('brokerId', $memberInfo['ajkMemberId'])->get_row(); if (!empty($ajkBrokerInfo) && $ajkBrokerInfo['userId']) { $balanceInfo = Bll_Service_Payment::balance(Bll_Service_Payment::SITE_ANJUKE, array('userId' => $ajkBrokerInfo['userId'])); if ($balanceInfo['status'] == 'error') { return -1; } return $balanceInfo['data']['balance']; } } return -1; }
/** * 增加money产生的公共动作 * @param string $descript * @throws Exception_BllErrorException */ private function addMoneyCommon($descript = '') { // 上线前判断余额 Jackin $userId = Bll_Broker_MainBusiness::getDataByEsfId($this->params['ajk_broker_id'])->memberId; try { $balanceInfo = Bll_Service_Payment::balance(Const_PaymentApp::HZ_DEFAULT, array('userId' => $userId)); } catch (Exception $e) { throw new Exception_BllErrorException(sprintf('调用api失败: %s userId=%d broker_id=%d ajk_broker_id=%d', $e->getMessage(), $userId, $this->params['broker_id'], $this->params['ajk_broker_id'])); } if ($balanceInfo['status'] == 'error') { throw new Exception_BllErrorException(sprintf('%s ajkBrokerId(%d) 获取余额失败', $descript, $this->params['ajk_broker_id'])); } elseif ($balanceInfo['data']['balance'] <= 0) { throw new Exception_BllErrorException(sprintf('%s ajkBrokerId(%d) 余额(%d)不足', $descript, $this->params['ajk_broker_id'], $balanceInfo['data']['balance'])); } $this->allReturn = array(sprintf('hz:%s ajkBrokerId(%d) 当前余额(%d) ', $descript, $this->params['ajk_broker_id'], $balanceInfo['data']['balance'])); //获取刷爆$descript的计划 $plans = Dao_Broker_HzPlan::get_broker_plan($this->params['broker_id'], 7); if (empty($plans)) { $this->allReturn[] = '没有获取到 status=7 的计划'; return; } $plan_ids = array(); foreach ($plans as $plan) { $plan_ids[] = $plan['id']; } // 获取所有房子并上线 $plans_props = Bll_HzFixPlan::get_plan_props($plan_ids, $this->params['city_id']); if (empty($plans_props)) { $this->allReturn[] = sprintf('没有获取到计划(%s)的房源', implode(',', $plan_ids)); return; } foreach ($plans_props as $plan_id => $props) { // 更新计划状态 if (Bll_HzPropBll::switchUpOrDown()) { if (!Dao_Broker_HzPlan::update_plan_status($plan_id, Const_HzPlan::SPREAD)) { $this->allReturn[] = "更新计划[{$plan_id}]数据失败"; } } else { $this->allReturn[] = "开关关闭,计划[{$plan_id}]数据不再更新"; } // 记录计划上线日志 $data = Bll_HzFixPlanBll::build_plan_log($this->params, 8, "{$descript},计划上线", $this->params['broker_id']); if (!Model_House_UpDown_PlanLog::create($data, date('m'))->save()) { $this->allReturn[] = "{$descript},计划[{$plan_id}]上线写入失败"; } else { $this->allReturn[] = "{$descript},计划[{$plan_id}]上线写入"; } foreach ($props['props'] as $prop) { if (Bll_HzPropBll::switchUpOrDown()) { if (Dao_Broker_HzProp::change_prop_status($prop['proid'], Const_HzStatus::ONLINE) && Model_Plan_HzPlanning::updatePlanningByPropId($prop['proid'], Const_HzPlan::SPREAD, Const_HzPlan::SPREAD_TYPE)) { $this->allReturn[] = "房源{$prop['proid']}上线成功"; } else { $this->allReturn[] = "房源{$prop['proid']}上线失败"; } } else { $all_return[] = "开关关闭,房源[{$prop['proid']}]状态不改变"; } $data = Bll_HzPropBll::build_prop_log($this->params, 5, "房源上线", $this->params['broker_id']); $data['planId'] = $plan_id; $data['houseId'] = $prop['proid']; if (!Model_Log_HouseLogNew::create($data, date('Ymd'))->save()) { $this->allReturn[] = "房源{$prop['proid']}上线日志写入失败"; } else { $this->allReturn[] = "房源{$prop['proid']}上线日志写入"; } } } }
/** * 获取经纪人的账户余额,单位:分 * * @param int $brokerId * @return int */ public static function getAccountBalance($brokerId) { $userId = Bll_Broker_MainBusiness::getDataByEsfId($brokerId)->memberId; $balanceInfo = Bll_Service_Payment::balance(Bll_Service_Payment::SITE_ANJUKE, array('userId' => $userId)); if ($balanceInfo['status'] == 'error') { return -1; } return $balanceInfo['data']['balance']; }