/** * 获取账户信息 * @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); }
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)); }
/** * 增加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']}上线日志写入"; } } } }
public function handle_request() { $houses = $this->getHouses(); if (!empty($_SERVER['PG_TEST'])) { //如果是PG $commIds = APF::get_instance()->get_config('pg_test_communitys_id', 'apiTestId'); } else { $commIds = APF::get_instance()->get_config('test_communitys_id', 'apiTestId'); } foreach ($houses as $house) { //是否收费 $pushOpen = Bll_Broker_EntrustPrice::getInstance()->checkCityConsumeStatus($house['cityId']); //城市是否开通房源库 //$cityInfo = Bll_Fyk_Prop_Manage::getInstance()->getCityConfig($house['cityId']); $community = $this->getCommunity($house['commId']); if (empty($community) || !$community['sosolat'] || !$community['sosolng']) { $this->setLog(date('Y-m-d H:i:s') . ' - propId: ' . $house['id'] . ',no around community'); // 更新游标 $this->cursor['id'] = $house['id']; $this->setFlag($this->cursor); continue; } //两公里经纪人获取------3.7版本以上或者免费城市3.4版本以上 $brokerIds = $this->getBroker2K($house['commId'], $community['sosolat'], $community['sosolng'], $commIds, $pushOpen, $house['id']); /** * 板块推送功能关闭,后期将会删除 */ /* if (empty($brokerIds)) { //板块下经纪人-》------3.7版本以上或者免费城市3.4版本以上 如果是测试小区测试经纪人id已经是存在的这里就没判断测试小区。 $brokerIds = $this->areaEntrustBroker($community['areaCode'],$pushOpen,$house['cityId'],$house['id']); } */ if (empty($brokerIds)) { $this->setLog(date('Y-m-d H:i:s') . ' - propId: ' . $house['id'] . ',commid: ' . $community['commId'] . ',no around broker'); // 更新游标 $this->cursor['id'] = $house['id']; $this->setFlag($this->cursor); continue; } $tmp = array_values(APF::get_instance()->get_config('test_broker_id', 'apiTestId')); $brokerIdsArr = $tmp[0]; foreach ($brokerIds as $brokerId) { $brokerInfoForAjkBrokerExtend = Model_Broker_AjkBrokerExtend::getDataByBrokerId($brokerId); if (!in_array($brokerId, $brokerIdsArr) && $house['cityId'] != $brokerInfoForAjkBrokerExtend['cityId']) { $this->setLog(date('Y-m-d H:i:s') . " - house: {$house['id']} and broker: {$brokerId} not in the same city."); continue; } echo '执行队列插入' . "\n"; Model_House_CommissionHousePushed::create(array('userId' => Bll_Broker_MainBusiness::getDataByEsfId($brokerId)->memberId, 'brokerId' => $brokerId, 'propertyId' => $house['id'], 'createTime' => date('Y-m-d H:i:s'), 'propertyStatus' => $house['proStatus'], 'robNum' => $house['openBrokerCnt']))->save(); echo '更新可抢插入' . "\n"; // 更新可抢房源数 $daCommissionHousePushedCount = Model_House_CommissionHousePushedCount::data_access()->filter('brokerId', $brokerId)->find_only(); if (!empty($daCommissionHousePushedCount)) { $daCommissionHousePushedCount->incrCommissionHousePushedCount(); } else { Model_House_CommissionHousePushedCount::create(array('brokerId' => $brokerId, 'total' => 1))->save(); } } echo '完成' . "\n"; // 更新游标 $this->cursor['id'] = $house['id']; $this->setFlag($this->cursor); } }
/** * 精选房源冻结 * * @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 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']; }
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; }
/** * * 获取经纪人的竞价房源数 * * @param $brokerId * @param $cityId * @param $siteType * @return int */ public static function getBrokerBidNum($brokerId, $cityId, $siteType) { $num = 0; switch ($siteType) { case 'ajk': $bidList = Model_Plan_EsfAjkPropSpread::getValidPlan($brokerId, $cityId, true); foreach ($bidList as $bid) { if ($bid['status'] == 1) { $num += 1; } } break; case 'hz': $brokerMapping = Bll_Broker_MainBusiness::getDataByEsfId($brokerId); //根据 $bidList = Model_Plan_HzPlanBasic::get_online_bid_plan_ex($brokerId, 2); $num = count($bidList); break; case 'jp': $brokerMapping = Bll_Broker_MainBusiness::getDataByEsfId($brokerId); //根据经纪人查询商铺相应 $bidList = Model_Plan_Jp::getPlanByMemberId($brokerMapping['jpBrokerid'], 2, array(2)); $num = count($bidList); break; default: break; } return $num; }
/** * 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); }
/** * 获取经纪人的账户余额,单位:分 * * @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']; }