예제 #1
0
 public function handle_request()
 {
     $params = array('id' => 123, 'type' => 101, 'broker_id' => 723767, 'pro_id' => 16228203, 'plan_id' => 22232, 'remark' => '');
     $hzUpDownService = new Bll_House_UpDown_Worker_HzUpDownService($params);
     //print_r($hzUpDownService->doUpDownFromWorker());
     var_dump(Model_Plan_HzPlanning::updatePropPlanStatusByPlanId(165122, Const_HzPlan::MENUOVER));
 }
예제 #2
0
 /**
  * 由于套餐变更 下掉多余房子
  * @param $brokerId
  * @param $shouldNum
  * @return array
  */
 public static function deleteExtraHouse($brokerId, $shouldNum)
 {
     $allReturn = array();
     // 转好租brokerid
     if (!($hzBrokerId = Model_Broker_HzMapping::get_hz_broker_id($brokerId))) {
         return Util_GlobalFunc::buildReturn(0, "租房-该经纪人:{$brokerId}获取不到租房经纪人id");
     }
     // 获取有效推广关系
     if (!($plannings = Model_Plan_HzPlanning::getPlanningLists(array('user_id' => $hzBrokerId, 'plan_type' => Const_HzPlan::SPREAD_TYPE, 'is_valid' => Const_HzPlan::SPREAD), 1000, array('proid', 'asc')))) {
         return Util_GlobalFunc::buildReturn(0, "租房-该经纪人:{$hzBrokerId}没有有效定价推广关系");
     }
     $num = count($plannings);
     //推广房源数
     echo '正在处理租房 hzBrokerId:' . $hzBrokerId . ',总推广房源数' . $num . ',api中允许推广数量' . $shouldNum . PHP_EOL;
     if ($num > $shouldNum) {
         // 应该下掉多余房子
         $offNum = $num - $shouldNum;
         foreach ($plannings as $key => $planning) {
             if ($offNum < $key + 1) {
                 break;
             }
             // 下房子动作
             $result = Bll_HzFixPlan::prop_out_fix($planning['user_id'], $planning['proid'], $planning['plan_id']);
             $allReturn[] = $result['msg'];
         }
     }
     return Util_GlobalFunc::buildReturn(1, $allReturn);
 }
예제 #3
0
 public function handle_request_internal()
 {
     $ajkBrokerId = $this->_params['brokerId'];
     //根据安居客经纪人ID获取好租经纪人ID
     $hzBrokerId = Bll_HzBroker::get_brokerid_by_ajk_brokerid($ajkBrokerId);
     //获取租房定价信息
     $fixPlansInfo = Bll_HzFixPlan::get_broker_fixplans($hzBrokerId);
     //获取竞价计划状态
     $fixPlanStatus = $fixPlansInfo[0]['status'] == 1 ? V1_Zufang_Fix_SummaryController::RETURN_CODE_NUM_1 : V1_Zufang_Fix_SummaryController::RETURN_CODE_NUM_0;
     //获取计划ID
     $fixPlanId = $fixPlansInfo[0]['id'];
     $cityId = $fixPlansInfo[0]['city_id'];
     //获取租房点击和花费信息
     $promotion = Dao_Broker_HzPlan::get_plan_fee($hzBrokerId, $fixPlanId, date('Ymd'), 1);
     // 获取租房今日点击
     $fixPropIds = Model_Plan_HzPlanning::getFixPropIdsByPlanId($fixPlanId);
     $clicks = Model_Stats_PropClick::getPropBidClick($fixPropIds, $hzBrokerId, $cityId);
     $fixClickSums = Model_Stats_PropClick::calculateClickSumsGroupByPropId($clicks, 'fix');
     $todayClicks = 0;
     foreach ($fixClickSums as $clickSum) {
         $todayClicks += $clickSum;
     }
     //租房某计划的房源总量
     $totalProps = Model_Plan_HzPlanning::getFixPlanPropNum($fixPlanId);
     //查询经纪人新封顶模式信息
     //todo 等多档封顶合并了方法迁移到多档封顶
     $ppcLimitInfo = $this->getPpcBrokerLimitInfo($ajkBrokerId, V1_Zufang_Fix_SummaryController::PPC_BROKER_LIMIT_HZ_SITE);
     if (!$ppcLimitInfo) {
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => Const_APIStatus::E_SYS_ERR, 'message' => '封顶数据未能取到!');
     }
     $todayConsume = $promotion[$fixPlanId]['total_cost'] ? $promotion[$fixPlanId]['total_cost'] : 0;
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('planId' => $fixPlanId, 'todayClicks' => $todayClicks, 'todayConsume' => Util_Formatter::formatTodayConsume($todayConsume), 'todayConsumeUnit' => '元', 'totalProps' => $totalProps, 'planStatus' => $fixPlanStatus, 'budget' => $ppcLimitInfo['amountLimit'] / 100, 'budgetUnit' => '元'));
 }
예제 #4
0
 public function handle_request_internal()
 {
     $ajkBrokerId = $this->_params['brokerId'];
     $propIds = $this->_params['propIds'];
     $arrPropId = explode(',', $propIds);
     $plans = Model_Plan_HzPlanning::getBidRelationsByHouseIds($arrPropId);
     $arrPlanId = array();
     foreach ($plans as $plan) {
         $arrPlanId[] = $plan->plan_id;
     }
     //删除已停止的精选计划
     //全部失败则返回调用失败,
     //只要有一个成功,则接口返回成功
     $flag = 0;
     foreach ($arrPlanId as $planId) {
         $rs = Bll_Plan_Bid_HzBid::deleteChoicePlan($ajkBrokerId, $planId);
         if ($rs['status'] == 'ok') {
             $flag = 1;
         }
     }
     if ($flag == 1) {
         return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array());
     } else {
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => Const_APIStatus::E_SYS_ERR, 'message' => '删除失败!');
     }
 }
예제 #5
0
 /**
  * 添加日志
  *
  * @param $propId
  * @param $option
  * @param $userId
  * @param $mid
  * @param $statusOld
  * @param $statusNew
  * @param bool $planIdOld
  * @param bool $planIdNew
  */
 public static function addEffectPropLog($propId, $option, $userId, $mid, $statusOld, $statusNew, $planIdOld = false, $planIdNew = false)
 {
     if ($planIdOld === false) {
         // 计划没有变更
         $propPlanInfo = Model_Plan_HzPlanning::getValidPropPlanByPropId($propId);
         if (!empty($propPlanInfo)) {
             $planIdOld = $propPlanInfo['plan_id'];
         } else {
             $planIdOld = 0;
         }
     }
     if ($planIdNew === false) {
         $planIdNew = $planIdOld;
     }
     $LogContent = array('proid' => $propId, 'option' => $option, 'user_id' => $userId, 'mid' => $mid, 'create_day' => date("Ymd"), 'created' => time(), 'status_old' => $statusOld, 'status_new' => $statusNew, 'plan_id_old' => $planIdOld, 'plan_id_new' => $planIdNew);
     Model_Log_EffectPropLog::addLog($LogContent);
 }
 public function dealTask($task)
 {
     $planId = $task['id'];
     // 查询对应关系
     $planning = Model_Plan_HzPlanning::getPlanByPlanId($planId);
     if (count($planning) > 0) {
         return true;
     }
     // 不需要处理
     // 获取当时的房子
     Model_Choice_ActionQueue::data_access(date('m', $task['created']))->filter('siteType', 2)->filter('status', self::ENUM_FAIL)->get_row();
     // 解冻
     // 更新计划删除
     // 记录有问题精选计划id
     file_put_contents('/data1/logs/Zufang_FixExistOnLineChoicePlanNoPlanning_ErrorPlanIds', $planId . PHP_EOL, FILE_APPEND);
     return true;
 }
예제 #7
0
 /**
  * 获取租房房源的推广状态
  *
  * @param int|array $houseId
  * @return array
  */
 private function getHouseSpreadStateHz($houseId)
 {
     $result = array('spread_house' => array(), 'not_spread_house' => array());
     try {
         $dataAccess = Model_Plan_HzPlanning::data_access('');
         $dataAccess->filter('proid', $houseId);
         $dataAccess->filter('is_valid', 1);
         $dataAccess->filter('plan_type', Model_Plan_HzPlanning::BID_OR_CHOICE_PLAN);
         $housePlanRelationList = $dataAccess->get_all();
     } catch (Exception $e) {
         return $result;
     }
     if (empty($housePlanRelationList)) {
         $result['not_spread_house'] = is_array($houseId) ? $houseId : array($houseId);
         return $result;
     }
     $planHouseMapping = array();
     foreach ($housePlanRelationList as $housePlanRelation) {
         $planHouseMapping[$housePlanRelation['plan_id']] = $housePlanRelation['proid'];
     }
     try {
         $dataAccess = Model_Plan_HzPlanBasic::data_access('');
         $dataAccess->filter('id', array_keys($planHouseMapping));
         $dataAccess->filter('flag', 1);
         $dataAccess->filter('plan_type', Model_Plan_HzPlanning::BID_OR_CHOICE_PLAN);
         $dataAccess->filter('bid_version', 2);
         $dataAccess->filter('status', 1);
         $planList = $dataAccess->get_all();
     } catch (Exception $e) {
         $result['not_spread_house'] = is_array($houseId) ? $houseId : array($houseId);
         return $result;
     }
     if (empty($planList)) {
         $result['not_spread_house'] = is_array($houseId) ? $houseId : array($houseId);
         return $result;
     }
     foreach ($planList as $planInfo) {
         $result['spread_house'][] = $planHouseMapping[$planInfo['id']];
     }
     if (!is_array($houseId)) {
         $houseId = array($houseId);
     }
     $result['not_spread_house'] = array_diff($houseId, $result['spread_house']);
     return $result;
 }
예제 #8
0
 public function handle_request()
 {
     if ($this->_cityId == 0) {
         $this->setLog('city Id 为必须传的参数');
         return;
     }
     if (!isset($this->_solrCityMapping[$this->_cityId])) {
         $this->setLog(sprintf('cityId[%d] 对应的solr配置不存在', $this->_cityId));
         return;
     }
     $searchParams = array('__test__' => __CLASS__ . time(), 'fl' => 'id', 'q' => '*:*', 'rows' => 10000, 'wt' => 'json');
     $fieldQuery = array('fq=' . urlencode('is_hp:1'), 'fq=' . urlencode(sprintf('city_id:%d', $this->_cityId)));
     $query = http_build_query($searchParams);
     $url = $this->getSolrUrl($this->_cityId) . '?' . $query . '&' . implode('&', $fieldQuery);
     $houseInSolrTemp = $this->httpRequest($url);
     if (empty($houseInSolrTemp)) {
         $this->setLog('在solr中的没有房源');
         return;
     }
     foreach ($houseInSolrTemp as $house) {
         $houseId = $house['id'];
         $this->setLog(sprintf('开始处理房源[%d]', $houseId));
         $housePlanning = Model_Plan_HzPlanning::getPropBidPlan($houseId, true);
         if (!empty($housePlanning)) {
             $ajkBrokerId = $housePlanning['ajkBrokerId'];
             $choicePlan = Model_Plan_HzPlanBasic::get_plan_by_id($housePlanning['plan_id'], true);
             $this->setLog(sprintf('房源[%d]的精选计划[%d]信息[bid_version=%d, status=%d]', $houseId, $housePlanning['plan_id'], $choicePlan['bid_version'], $choicePlan['status']));
             if (!empty($choicePlan) && $choicePlan['bid_version'] == Const_HzPlan::BID_TYPE && $choicePlan['status'] == Const_HzPlan::SPREAD) {
                 continue;
             }
         } else {
             $this->setLog(sprintf('没有获取到房源[%d]的计划关系信息', $houseId));
             $propSearchInfo = Model_House_HzPropSearch::get_prop_by_prop_id($this->_cityId, $houseId);
             if (empty($propSearchInfo) || $propSearchInfo['ajkBrokerId'] == 0) {
                 $this->setLog(sprintf('没有获取到房源[%d]的经纪人ID', $houseId));
                 continue;
             }
             $ajkBrokerId = $propSearchInfo['ajkBrokerId'];
         }
         $this->setLog(sprintf('需要下架房源 [%d - %d - %d]', $houseId, $ajkBrokerId, $this->_cityId));
         // $res = Bll_Combo_NoticeSolrUpDown::noticeChoiceSolrZfAPI($this->_cityId, $ajkBrokerId, $houseId, 2, 2, Bll_Combo_NoticeSolrUpDown::HLSFromChoiceUpDown, time());
         // $this->setLog('通知solr res: ' . json_encode($res));
     }
 }
예제 #9
0
 public function handle_request_internal()
 {
     $brokerId = $this->_params['brokerId'];
     $propId = $this->_params['propId'];
     // 获取Broker Mapping
     $brokerMapping = Model_Broker_MainBusiness::getMainBusinessByAjkBrokerId($brokerId);
     if (!$brokerMapping) {
         throw new Exception('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS);
     }
     $data = array();
     // 获取房源和计划关系
     $planRelation = Model_Plan_HzPlanning::getPropFixPlan($propId);
     if ($planRelation) {
         $data['status'] = 1;
         //推广中
     } else {
         $data['status'] = 0;
         //未推广
     }
     // 获取房源信息
     $prop = Model_House_HzProp::data_access()->filter('propId', $propId)->find_only();
     if (!$prop) {
         throw new Exception('房源不存在', Const_APIStatus::E_PROP_NOT_EXISTS);
     }
     // 判断房源和经纪人关联关系
     $propBasic = json_decode($prop['contentBasic'], true);
     if ($propBasic['userid'] != $brokerMapping['hzBrokerid']) {
         throw new Exception('房源不属于该经纪人', Const_APIStatus::E_PROP_NOT_EXISTS);
         // TODO
     }
     // 根据房源的计划ID判断房源是否已定价推广
     $data['planId'] = '';
     if ($plan = $prop->getFixPlan()) {
         $data['planId'] = $plan['id'];
     }
     // 点击单价
     $data['clickPrice'] = round($prop->getFixClickPrice(), 2);
     $data['clickPriceUnit'] = '元';
     // 今日定价点击量
     $data['todayClicks'] = $prop->getTodayClickSums('fix');
     // 定价点击总量
     $data['totalClicks'] = $prop->getTotalClickSums('fix');
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => $data);
 }
 /**
  * 统计房源在线时长
  *
  * @param int $brokerId
  * @param int $propId
  * @param int $propStatus
  */
 public function countHouseOnlineStatistics($brokerId, $propId, $propStatus)
 {
     $this->logMessage(sprintf('开始统计房源在线时长: brokerId=%d, propId=%d, propStatus=%d', $brokerId, $propId, $propStatus));
     $propChangeLogList = Model_House_HzProChangeLog::getChangeListLogByProId($propId, date('Ymd', strtotime('-1 day')));
     /** 如果房源没有操作日志,且房源在线,则去计划表查询,如果计划在线则24小时在线否则不记录 */
     if (empty($propChangeLogList) && $propStatus == Const_HzStatus::ONLINE) {
         $this->logMessage(sprintf('房源(%d)在线,但是昨天没有操作记录', $propId));
         $propPlannings = Model_Plan_HzPlanning::getPlanningByPropId($propId);
         foreach ($propPlannings as $propPlanning) {
             if ($propPlanning['is_valid'] != Const_HzPlan::SPREAD) {
                 continue;
             }
             $propPromotionTime = array('propId' => $propId, 'brokerId' => $brokerId, 'planId' => $propPlanning['plan_id'], 'planType' => $propPlanning['plan_type'], 'onlineDate' => date('Ymd', strtotime('-1 day')), 'onlineHour' => 24.0, 'minOnlineDatetime' => date('Y-m-d H:i:s', $this->yesterdayStartTimeStamp), 'maxOfflineDatetime' => date('Y-m-d H:i:s', $this->yesterdayEndTimeStamp));
             $this->savePropPromotionTime($propPromotionTime);
         }
         return;
     }
     $propChangeInfo = array();
     /** 只使用最后一个记录 */
     foreach ($propChangeLogList as $propChangeLog) {
         $propChangeInfo[$propChangeLog['type']] = $propChangeLog;
     }
     foreach ($propChangeLogList as $spreadType => $lastPropChangeLog) {
         /** 最后一条记录为上架操作 */
         if ($lastPropChangeLog['action'] == Model_House_HzProChangeLog::HOUSE_CHANGE_ACTION_UP) {
             $onlineHour = $lastPropChangeLog['time'] + ($this->yesterdayEndTimeStamp - strtotime($lastPropChangeLog['logTime']));
             $minOnlineDatetime = $lastPropChangeLog['logTime'];
             $maxOfflineDatetime = date('Y-m-d H:i:s', $this->yesterdayEndTimeStamp);
         } else {
             /** 最后一条数据为下架操作 */
             if ($lastPropChangeLog['time'] == 0) {
                 $onlineHour = strtotime($lastPropChangeLog['logTime']) - $this->yesterdayStartTimeStamp;
             } else {
                 $onlineHour = $lastPropChangeLog['time'];
             }
             $minOnlineDatetime = date('Y-m-d H:i:s', $this->yesterdayStartTimeStamp);
             $maxOfflineDatetime = $lastPropChangeLog['logTime'];
         }
         $onlineHour = $onlineHour > 86400 ? 86400 : $onlineHour;
         $propPromotionTime = array('propId' => $propId, 'brokerId' => $brokerId, 'planId' => $lastPropChangeLog['spreadId'], 'planType' => $spreadType, 'onlineDate' => date('Ymd', strtotime('-1 day')), 'onlineHour' => round($onlineHour / 60, 1), 'minOnlineDatetime' => $minOnlineDatetime, 'maxOfflineDatetime' => $maxOfflineDatetime);
         $this->savePropPromotionTime($propPromotionTime);
     }
 }
예제 #11
0
 public function handle_request()
 {
     $startTime = strtotime(date('Y-m-d 00:00:00'));
     $this->logOut(sprintf('[%s] 开始修复没有房源关系的精选计划', date('Y-m-d H:i:s')));
     $choiceWaitPlanList = Model_Plan_HzPlanBasic::getAllChoiceWaitPlan($startTime);
     if (empty($choiceWaitPlanList)) {
         $this->logOut('    没有获取到计划。');
         return;
     }
     foreach ($choiceWaitPlanList as $choiceWaitPlan) {
         $this->logOut(sprintf('    开始修复经纪人(%d)的精选计划(%d)。', $choiceWaitPlan['user_id'], $choiceWaitPlan['id']));
         $propPlanning = Model_Plan_HzPlanning::getPlanByPlanId($choiceWaitPlan['id']);
         if (!empty($propPlanning)) {
             $this->logOut('    无需修复, 计划(%d)关联到房源(%d)。', $choiceWaitPlan['id'], $propPlanning['proid']);
             continue;
         }
         /** TODO 思考是否要修复 坑位表 */
     }
 }
예제 #12
0
 public function handle_request_internal()
 {
     $ajkBrokerId = $this->_params['brokerId'];
     $propId = $this->_params['propId'];
     //通过房源获取计划
     $objPlan = Model_Plan_HzPlanning::getBidRelationsByHouseIds($propId);
     $objPlan = array_shift($objPlan);
     //获取IP
     $ip = $this->_request->get_client_ip();
     //停止精选计划
     if ($objPlan->is_valid == Const_HzPlan::SPREAD) {
         $rs = Bll_Plan_Bid_HzBid::stopChoicePlan($ajkBrokerId, $objPlan->plan_id, $ip);
     } elseif ($objPlan->is_valid == Const_HzPlan::WAITING) {
         $rs = Bll_Plan_Bid_HzBid::stopChoiceQueue($ajkBrokerId, $objPlan->plan_id, $ip);
     } else {
         $rs['status'] = 'error';
         $rs['msg'] = '计划状态错误!';
     }
     if ($rs['status'] != 'ok') {
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => Const_APIStatus::E_SYS_ERR, 'message' => $rs['msg']);
     }
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('msg' => '精选结束成功'));
 }
예제 #13
0
 public function get_plan_by_proid($proid)
 {
     return Model_Plan_HzPlanning::data_access()->filter('proid', $proid)->filter('plan_type', 2)->find_only();
 }
예제 #14
0
 /**
  * 警告:未得到授权,不能使用。所有者:caoyang
  * 本方法为租房架构变更,房源状态维护的过渡期中临时方法。有效到2014-10-01。
  *
  * 根据当前定价、竞价(精选)的状态维护房源的状态
  * 1.房源的状态为:违规-6,删除-99、100的时候房源的状态不被更新
  * 2.定价、竞价(精选)任意一个推广时房源状态为1
  * 3.房源不在定价计划中的时候状态需要维护成2、4
  *
  * @param $hzProId
  * @return mixed
  */
 public static function bulidHzProStatu($hzProId)
 {
     /** 房源信息初步判断 */
     //查询房源信息
     $proInfo = Model_House_HzProp::get_prop_info_by_prop_id($hzProId);
     if (empty($proInfo)) {
         //房源信息不存在
         return '';
     }
     if (in_array($proInfo['contentBasic']['status'], array(Const_HzStatus::VERIFY, Const_HzStatus::REMOVE, Const_HzStatus::EXPIRED))) {
         //房源状态为违规的、删除的不能更新房源状态
         return '';
     }
     /** 定价、竞价(精选)数据准备 */
     //查询租房定价、竞价(精选)关系数据
     $fixPlanning = array();
     //定价关系数据
     $bidPlanning = array();
     //竞价(精选)关系数据
     $comboRelation = array();
     // 套餐关系数据
     //$isComboBroker = Bll_Broker_HzBroker::isComboBroker($proInfo['contentBasic']['user_id']);
     $planning = Model_Plan_HzPlanning::data_access()->filter('proid', $hzProId)->get_all();
     foreach ($planning as $list) {
         //定价
         if ($list['plan_type'] == Const_HzPlan::SPREAD_TYPE) {
             $fixPlanning = $list;
         }
         //竞价(精选)
         if ($list['plan_type'] == Const_HzPlan::BID_TYPE) {
             $bidPlanning = $list;
         }
     }
     //查询租房竞价(精选)计划状态
     if (empty($bidPlanning)) {
         $bidPlanInfo = array();
     } else {
         $bidPlanInfo = Model_Plan_HzPlanBasic::get_plan_by_id($bidPlanning['plan_id']);
     }
     //查询租房定价计划状态
     if (empty($fixPlanning)) {
         $fixPlanInfo = array();
     } else {
         $fixPlanInfo = Model_Plan_HzPlanBasic::get_plan_by_id($fixPlanning['plan_id']);
     }
     //查询套餐关系
     $comboRelation = Bll_Combo_HouseRelation::getRelationByHouseId($hzProId);
     /** 计算出房源状态应该更新成什么样 */
     /**
      * 1. 非定价推广(计划删除、或房源不在计划里面)proStatus=2
      * 2. 定价推广:proStatus=1
      * 3. 定价非推广(房源在计划中)
      *  3.1 竞价(精选)非推广
      *      3.1.1 定价计划没钱 proStatus=13
      *      3.1.1 定价其他 proStatus=9
      *  3.2 竞价(精选)推广 proStatus=1
      */
     if ($comboRelation) {
         return Dao_Broker_HzProp::change_prop_status($hzProId, Bll_Combo_HouseRelation::isRelationOnline($comboRelation['state']) ? Const_HzStatus::ONLINE : Const_HzStatus::OUTLINE);
     } else {
         //定价计划不存在、计划标记为删除、计划不是正常状态(1、2、5、7、9)
         if (empty($fixPlanInfo) || $fixPlanInfo['flag'] == 0 || !in_array($fixPlanInfo['status'], array(Const_HzPlan::SPREAD, Const_HzPlan::AUTOOVER, Const_HzPlan::AWAIT, Const_HzPlan::UPPERLIMIT, Const_HzPlan::MANUALLY_PAUSE))) {
             return Dao_Broker_HzProp::change_prop_status($hzProId, Const_HzStatus::OUTLINE);
             //房源不在计划里面
         }
         //定价房源不在计划里面、非有效的关系(1、2、5、7、9)
         if (empty($fixPlanning) || !in_array($fixPlanning['is_valid'], array(Const_HzPlan::SPREAD, Const_HzPlan::AUTOOVER, Const_HzPlan::AWAIT, Const_HzPlan::UPPERLIMIT, Const_HzPlan::MANUALLY_PAUSE))) {
             return Dao_Broker_HzProp::change_prop_status($hzProId, Const_HzStatus::OUTLINE);
             //房源不在计划里面
         }
         //定价计划推广中
         if ($fixPlanInfo['status'] == Const_HzPlan::SPREAD) {
             return Dao_Broker_HzProp::change_prop_status($hzProId, Const_HzStatus::ONLINE);
             //房源正在推广
         }
         //竞价(精选)计划不存在、计划标记为删除、计划不是正常状态(1、2、5、7、9、13)
         //竞价(精选)房源不在计划里面、非有效的关系(1、2、5、7、9、13)
         if (empty($bidPlanInfo) || $bidPlanInfo['flag'] == 0 || !in_array($bidPlanInfo['status'], array(Const_HzPlan::SPREAD, Const_HzPlan::AUTOOVER, Const_HzPlan::AWAIT, Const_HzPlan::UPPERLIMIT, Const_HzPlan::MANUALLY_PAUSE, Const_HzPlan::WAITING)) || empty($bidPlanning) || !in_array($bidPlanning['is_valid'], array(Const_HzPlan::SPREAD, Const_HzPlan::AUTOOVER, Const_HzPlan::AWAIT, Const_HzPlan::UPPERLIMIT, Const_HzPlan::MANUALLY_PAUSE, Const_HzPlan::WAITING))) {
             if ($fixPlanInfo['status'] == Const_HzPlan::UPPERLIMIT) {
                 //计划没钱
                 return Dao_Broker_HzProp::change_prop_status($hzProId, Const_HzStatus::NOCASH);
                 //房源没钱
             } else {
                 return Dao_Broker_HzProp::change_prop_status($hzProId, Const_HzStatus::MANUALLY);
                 //房源状态更新为9手动停止
             }
         }
         //竞价(精选)推广
         if ($bidPlanInfo['status'] == Const_HzPlan::SPREAD) {
             return Dao_Broker_HzProp::change_prop_status($hzProId, Const_HzStatus::ONLINE);
             //房源正在推广
         }
     }
     //以上逻辑都没走到,记录当时错误情况
     file_put_contents("/data1/logs/bulidHzProStatu.log", date('Y-m-d H:i:s') . " " . $hzProId . " " . json_encode($fixPlanInfo) . " " . json_encode($fixPlanning) . " " . json_encode($bidPlanInfo) . " " . json_encode($bidPlanning) . "\n", FILE_APPEND);
     return false;
 }
예제 #15
0
 /**
  * 精选房源设置页面
  *
  * @param int $ajk_broker_id
  * @param int $city_id
  * @param int $prop_id
  * @param array $params
  *
  * @return array
  */
 public static function hz_setting($ajk_broker_id, $city_id, $prop_id, $params = array())
 {
     $pageAttribute = array('broker_id' => $ajk_broker_id, 'prop_id' => $prop_id);
     //获取精选推广预算
     $brokerInfo = Bll_BrokerBaseBll::get_instance()->get_broker_info($ajk_broker_id);
     $brokerCompanyId = $brokerInfo['BaseInfo']['COMPANYID'];
     $choiceSet = APF::get_instance()->get_config('choice_set');
     if (isset($choiceSet[$brokerCompanyId]) && !empty($choiceSet[$brokerCompanyId])) {
         $pageAttribute['min_budget'] = $choiceSet[$brokerCompanyId]['hz']['HZ_CHOICE_MIN_BUDGET'];
         $pageAttribute['max_budget'] = $choiceSet[$brokerCompanyId]['hz']['HZ_CHOICE_MAX_BUDGET'];
     } else {
         $pageAttribute['min_budget'] = $choiceSet['default']['hz']['HZ_CHOICE_MIN_BUDGET'];
         $pageAttribute['max_budget'] = $choiceSet['default']['hz']['HZ_CHOICE_MAX_BUDGET'];
     }
     $hz_broker_id = Model_Broker_HzMapping::get_hz_broker_id($ajk_broker_id);
     if (0 == $hz_broker_id) {
         return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '您不是好租经纪人');
     }
     /** 经纪人重新推广房源 */
     if (isset($params['act']) && $params['act'] == 'rebid') {
         $planInfo = Model_Plan_HzPlanBasic::get_plan_by_id($params['plan_id']);
         if ($planInfo['plan_type'] != 2 || $planInfo['bid_version'] != 2) {
             return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '房源所在的计划不是精选房源计划');
         }
         if ($planInfo['status'] == Const_HzPlan::WAITING || $planInfo['status'] == Const_HzPlan::SPREAD) {
             return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '房源已经精选');
         }
         $pageAttribute['plan_id'] = $params['plan_id'];
         $pageAttribute['rebid'] = true;
     } else {
         $propPlan = Model_Plan_HzPlanning::getPropBidPlan($prop_id);
         if (!empty($propPlan)) {
             $planInfo = Model_Plan_HzPlanBasic::get_plan_by_id($propPlan['plan_id']);
             if ($planInfo['bid_version'] == Const_HzPlan::BID_VERSION_CHOICE && ($planInfo['status'] == Const_HzPlan::WAITING || $planInfo['status'] == Const_HzPlan::SPREAD)) {
                 return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '房源已经精选');
             }
             if ($planInfo['bid_version'] == Const_HzPlan::BID_VERSION_CHOICE && $propPlan['is_valid'] != 0 && $planInfo['status'] != Const_HzPlan::DELETE && $planInfo['flag'] == 1) {
                 $pageAttribute['plan_id'] = $propPlan['plan_id'];
                 $pageAttribute['rebid'] = true;
             } else {
                 /** 检查 经纪人是不是 已经满足10套 */
                 $onlinePlanCount = Model_Plan_HzPlanBasic::count_online_bid_plan_ex($ajk_broker_id);
                 if ($onlinePlanCount >= self::ALL_ZF_PLAN_NUM) {
                     return array('err_no' => Bll_Plan_Bid_Choice::BID_FAIL_OTHER, 'err_msg' => '您最多可以对' . self::ALL_ZF_PLAN_NUM . '套房源做精选推广,请确认数量是否已经达到上限');
                 }
             }
         }
     }
     /** 获取房源基本信息 */
     $propInfo = Model_House_HzProp::get_prop_info_by_prop_id($prop_id);
     if (empty($propInfo)) {
         return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '房源不存在(code:-3)');
     }
     if (empty($propInfo['contentBasic']) || !isset($propInfo['contentBasic']['userid']) || $propInfo['contentBasic']['userid'] != $hz_broker_id) {
         return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '房源不存在(code:-2)');
     }
     if (false == $propInfo['contentBasic']['quality']) {
         return array('err_no' => self::BID_FAIL_QUALITY_OR_NEW, 'err_msg' => '多图、新发15天房源才能参与精选推广');
     }
     if (date('Ymd', strtotime('-15 days')) > date('Ymd', $propInfo['contentBasic']['created'])) {
         return array('err_no' => self::BID_FAIL_QUALITY_OR_NEW, 'err_msg' => '多图、新发15天房源才能参与精选推广');
     }
     /** 判断是否是精选开放城市 */
     if (!Bll_City::isChoiceIndependentCity($city_id, Const_Site::HAOZU)) {
         /** 判断房源是否在套餐推广 */
         $propCombos = Bll_Combo_HouseRelation::getOnlineRelationByHouseId($prop_id, Bll_Combo_HouseRelation::SITE_TYPE_HZ);
         if (empty($propCombos)) {
             return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '房源必须在套餐推广才能参与精选');
         }
     }
     $balance = self::get_broker_balance_by_broker_id($ajk_broker_id);
     $pageAttribute['balance'] = $balance;
     if ($balance > 0) {
         $balance = sprintf('%.2f', $balance / 100);
     }
     $pageAttribute['balance_fmt'] = $balance;
     /**
      * renttype: 1整租 2合租
      */
     if (empty($propInfo['contentBasic'])) {
         return array('err_no' => self::BID_FAIL_QUALITY_OR_NEW, 'err_msg' => '房源不存在(code:-4)');
     }
     /** 出租方式 */
     $rent_type = $propInfo['contentBasic']['renttype'] == 1 ? '整租' : '合租';
     /** 房屋类型 */
     $house_type_config = APF::get_instance()->get_config('housetype', 'house');
     $house_type = isset($house_type_config[$city_id]) ? $house_type_config[$city_id] : $house_type_config[0];
     $prop_type = isset($house_type[$propInfo['contentBasic']['protype']]) ? $house_type[$propInfo['contentBasic']['protype']] : '其他';
     /** 户型 */
     $room_amount = $propInfo['contentBasic']['roomnum'];
     $hall_amount = $propInfo['contentBasic']['hallnum'];
     $toilet_amount = $propInfo['contentBasic']['toilnetnum'];
     /** 出租面积 */
     $area_amount = $propInfo['contentBasic']['areanum'];
     /** 租金 */
     $price = $propInfo['contentBasic']['pricenum'];
     $title = $propInfo['contentBasic']['commname'];
     $blockInfo = Model_City_HzArea::getAreaById($propInfo['contentBasic']['blockid']);
     if (empty($blockInfo)) {
         $blockName = $title;
     } else {
         $blockName = $blockInfo['typeName'];
     }
     $pageAttribute['community_name'] = $blockName;
     /** 设置标题 */
     $pageAttribute['title'] = sprintf('%s,%d室%d厅%d卫,%d平,%s,%s,%d元/月', $title, $room_amount, $hall_amount, $toilet_amount, $area_amount, $rent_type, $prop_type, $price);
     $bucketInfo = Bll_Choice_HzBidBucket::get_bucket_info($propInfo['contentBasic']['blockid'], $city_id, $propInfo['contentBasic']['pricenum']);
     $pageAttribute['bucket_total'] = $bucketInfo['totalNum'];
     $pageAttribute['bucket_used'] = $bucketInfo['usedNum'];
     // 取出area的areacode  取查询  (由于dw存的blockid是areacode)
     $area = Model_City_HzArea::getAreaById($propInfo['contentBasic']['blockid']);
     $averageClickAndBudget = Bll_Choice_HzBidBucket::getBucketAverageClickBudget($area['typeCode'], $city_id, $propInfo['contentBasic']['pricenum']);
     if (!empty($averageClickAndBudget)) {
         $pageAttribute['averageClick'] = $averageClickAndBudget['averageClick'];
         $pageAttribute['averageBudget'] = $averageClickAndBudget['averageBudget'] / 100;
     }
     /** 获取点击单价 */
     try {
         $clickPrice = Bll_Service_Choice::hzClickPrice(array('brokerId' => $ajk_broker_id, 'cityId' => $city_id, 'price' => (int) $propInfo['contentBasic']['pricenum'], 'blockId' => $propInfo['contentBasic']['blockid']));
         if ($clickPrice['status'] == 'error') {
             return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '系统繁忙(code:-1)');
         }
     } catch (Exception $e) {
         return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '系统繁忙(code:-33)');
     }
     if ($clickPrice['realTradeAmount'] != $clickPrice['shouldTradeAmount']) {
         $pageAttribute['favorable'] = true;
         $pageAttribute['price'] = round($clickPrice['realTradeAmount'] / 100, 2);
         $pageAttribute['origin_price'] = round($clickPrice['shouldTradeAmount'] / 100, 2);
         $pageAttribute['favorable_end_time'] = isset($clickPrice['rebateEndTime']) ? $clickPrice['rebateEndTime'] : '';
     } else {
         $pageAttribute['favorable'] = false;
         $pageAttribute['price'] = round($clickPrice['realTradeAmount'] / 100, 2);
     }
     $pageAttribute['bucket_used_num'] = $bucketInfo['usedNum'];
     $pageAttribute['bucket_total_num'] = $bucketInfo['totalNum'];
     $pageAttribute['bucket_max_online_num'] = $bucketInfo['maxOnlineNum'];
     $pageAttribute['hidden']['show'] = $bucketInfo['maxOnlineNum'] > $bucketInfo['usedNum'] ? 1 : 0;
     $priceInfo = Model_House_HzPriceChoice::get_price_by_id($bucketInfo['priceId']);
     if (($pos = strpos('以', $priceInfo['title'])) !== false) {
         $priceInfo['title'] = substr($priceInfo['title'], 0, $pos) . '元' . substr($priceInfo['title'], $pos);
     } else {
         $priceInfo['title'] = $priceInfo['title'] . '元';
     }
     $pageAttribute['price_title'] = $priceInfo['title'];
     return $pageAttribute;
 }
예제 #16
0
 public function getChoicePlan()
 {
     // 获取房源和计划关系
     $planRelation = Model_Plan_HzPlanning::getPropBidPlan($this->propId);
     if (!$planRelation) {
         return null;
     }
     // 获取计划
     $plan = Model_Plan_HzPlanBasic::get_plan_by_id($planRelation['plan_id']);
     if (!$plan) {
         return null;
     }
     // 判断是否精选
     if ($plan->bid_version != 2) {
         return null;
     }
     return $plan;
 }
예제 #17
0
 public function handle_request_internal()
 {
     $brokerId = $this->_params['brokerId'];
     $cityId = $this->_params['cityId'];
     $planId = $this->_params['planId'];
     // 获取Broker Mapping
     $brokerMapping = Model_Broker_MainBusiness::getMainBusinessByAjkBrokerId($brokerId);
     if (!$brokerMapping) {
         throw new Exception('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS);
     }
     // 判断计划和经纪人关联关系
     $plan = Model_Plan_HzPlanBasic::get_plan_by_id($planId);
     if ($plan['user_id'] != $brokerMapping['hzBrokerid']) {
         throw new Exception('计划不属于该经纪人', Const_APIStatus::E_PLAN_NOT_BELONG_BROKER);
     }
     // 获取定价推广房源列表
     $propertyList = array();
     $props = Bll_HzFixPlan::get_plan_props($planId, $cityId);
     if (isset($props[$planId]) && isset($props[$planId]['props'])) {
         $propIds = array();
         foreach ($props[$planId]['props'] as $prop) {
             $propId = $prop['proid'];
             $propIds[] = $propId;
             $row = array();
             $row['propId'] = $row['id'] = $propId;
             $row['title'] = $prop['content_basic']['title'];
             $row['imgUrl'] = '';
             $row['commId'] = $prop['content_basic']['commid'];
             $row['commName'] = $prop['content_basic']['commname'];
             $row['roomNum'] = $prop['content_basic']['roomnum'];
             $row['hallNum'] = $prop['content_basic']['hallnum'];
             $row['toiletNum'] = $prop['content_basic']['toilnetnum'];
             $row['area'] = round($prop['content_basic']['areanum']);
             $row['price'] = round($prop['content_basic']['pricenum']);
             $row['priceUnit'] = '元/月';
             $row['todayClicks'] = $prop['fix_click'];
             $row['totalClicks'] = $prop['fix_total_click'];
             $row['isBid'] = 0;
             $row['isChoice'] = 0;
             $row['isVisible'] = (int) ($prop['content_basic']['status'] != 6);
             $row['isMoreImg'] = (int) $prop['content_basic']['quality'];
             $row['isPhonePub'] = (int) (isset($prop['content_basic']['from']) && $prop['content_basic']['from'] == 'mobile-ajk-broker');
             $row['publishDays'] = floor((time() - $prop['content_basic']['created']) / 86400);
             $row['publishDaysMsg'] = $row['publishDays'] > 0 ? "{$row['publishDays']}天前发布" : '今天发布';
             $row['createTime'] = date('Y-m-d H:i:s', $prop['content_basic']['created']);
             $row['updateTime'] = date('Y-m-d H:i:s', $prop['content_basic']['updated']);
             //增加委托房源标签
             $isEntrust = Bll_Zufang_Choice::isCommissionHouse($propId, $brokerId, Model_House_Commission::TYPE_RENT);
             if ($isEntrust) {
                 $row['isEntrust'] = 1;
             } else {
                 $row['isEntrust'] = 0;
             }
             $propertyList[$propId] = $row;
         }
         if ($propIds) {
             // 批量获取房源的默认图片
             $defaultImages = Model_Image_HzImage::getDefaultImagesByHouseIds($propIds);
             foreach ($defaultImages as $defaultImage) {
                 $propertyList[$defaultImage['proid']]['imgUrl'] = $defaultImage->imageUrl();
             }
             // 批量获取房源和竞价计划的关联记录(精选是竞价2.0)(只取推广中和排队中的关系)
             $relations = Model_Plan_HzPlanning::getBidRelationsByHouseIds($propIds, array(Const_HzPlan::SPREAD, Const_HzPlan::WAITING));
             // 批量获取房源竞价计划
             $planIds = array();
             $planPropMap = array();
             foreach ($relations as $relation) {
                 $planIds[] = $relation['plan_id'];
                 $planPropMap[$relation['plan_id']] = $relation['proid'];
             }
             if ($planIds) {
                 $plans = Model_Plan_HzPlanBasic::getPlansByIds($planIds);
                 foreach ($plans as $plan) {
                     // 忽略已删除计划
                     if ($plan->flag == 0) {
                         continue;
                     }
                     // 精选
                     if ($plan->bid_version == 2) {
                         $propId = $planPropMap[$plan['id']];
                         $propertyList[$propId]['isChoice'] = 1;
                     } else {
                         // 竞价
                         $propId = $planPropMap[$plan['id']];
                         $propertyList[$propId]['isBid'] = 1;
                     }
                 }
             }
         }
     }
     // 排序 • 按发布时间倒序
     usort($propertyList, function ($a, $b) {
         if ($a['createTime'] == $b['createTime']) {
             return 0;
         }
         return strtotime($a['createTime']) > strtotime($b['createTime']) ? -1 : 1;
     });
     // 分组
     $newList = array();
     $oldList = array();
     foreach ($propertyList as $property) {
         if ($property['publishDays'] > 30) {
             $oldList[] = $property;
         } else {
             $newList[] = $property;
         }
     }
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('newList' => $newList, 'oldList' => $oldList));
 }
예제 #18
0
 /**
  * 获取房源计划信息
  *
  * @param $propId
  * @return array
  */
 public static function getPropPlanType($propId)
 {
     $propFixPlan = Model_Plan_HzPlanning::getPropFixPlan($propId);
     $propBidPlan = Model_Plan_HzPlanning::getPropBidPlan($propId);
     $result = array();
     if (!empty($propFixPlan)) {
         $result['fix'] = array('isValid' => $propFixPlan['is_valid'], 'planId' => $propFixPlan['plan_id']);
         $result['type'] = 1;
     }
     if (!empty($propBidPlan)) {
         $result['bid'] = array('isValid' => $propBidPlan['is_valid'], 'planId' => $propBidPlan['plan_id']);
         $result['type'] = 2;
     }
     if (!empty($propBidPlan) && !empty($propFixPlan)) {
         $result['type'] = 3;
     }
     return $result;
 }
예제 #19
0
 public function handle_request_combo()
 {
     $ajkBrokerId = $this->brokerId;
     $cityId = $this->cityId;
     $siteType = Bll_Combo_Broker_BrokerComboInfo::SITE_TYPE_HZ;
     //首先获取套餐关系房源列表 ---- 那房源到主表去除status 已删除的房源 -----在房源主表获取房源基本信息
     $comboList = Bll_Combo_HouseRelation::getHouseRelations($ajkBrokerId, $siteType, 1);
     $surplus = $hasCombo = 0;
     //获取套餐信息-首先判断经纪人有无套餐
     $comboInfos = Bll_Combo_Broker_BrokerComboInfo::getComboListBySite($ajkBrokerId, $siteType);
     if (count($comboInfos) > 0) {
         $index = Bll_Combo_Broker_BrokerComboInfo::getComboIndexBySiteType($siteType);
         $currentTime = time();
         foreach ($comboInfos as $combo) {
             if ($combo[$index] == 0) {
                 continue;
             }
             if (strtotime($combo['endTime']) > $currentTime && strtotime($combo['startTime']) < $currentTime) {
                 $currentCombo = $combo;
             }
         }
         if (!empty($currentCombo)) {
             $surplus = $currentCombo['rentPropNum'];
             if (Bll_Combo_Broker_BrokerComboInfo::isOpenUp($currentCombo)) {
                 //商业地产没打通
                 $surplus = $currentCombo['rentPropNum'] + $currentCombo['salePropNum'];
             }
             $hasCombo = 1;
         }
     }
     //获取当前已推广套餐数量
     if (Bll_Combo_Broker_BrokerComboInfo::isOpenUp($currentCombo)) {
         $currentSpreadHouseCount = Bll_Combo_HouseRelation::getHouseCount($ajkBrokerId, $siteType, true);
     } else {
         $currentSpreadHouseCount = Bll_Combo_HouseRelation::getHouseCountEx($ajkBrokerId, $cityId, $siteType);
     }
     $oldList = $newList = array();
     if (empty($comboInfos)) {
         return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('newList' => $newList, 'oldList' => $oldList, 'surplus' => $surplus - $currentSpreadHouseCount, 'hasCombo' => $hasCombo));
     }
     $propIds = array();
     foreach ($comboList as $row) {
         $propIds[] = $row['houseId'];
     }
     $hzBrokerId = Bll_HzBroker::get_brokerid_by_ajk_brokerid($ajkBrokerId);
     $comboPropList = Model_House_HzPropSearch::getPropList($propIds, $hzBrokerId, $this->cityId);
     foreach ($comboPropList as $key => $list) {
         if (in_array($list['status'], array(Const_HzStatus::VERIFY, Const_HzStatus::REMOVE, Const_HzStatus::EXPIRED))) {
             unset($comboPropList[$key]);
         }
     }
     //fix bug45133
     if (empty($comboPropList)) {
         return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('newList' => $newList, 'oldList' => $oldList, 'surplus' => $surplus - $currentSpreadHouseCount, 'hasCombo' => $hasCombo));
     }
     $propIds = array();
     foreach ($comboPropList as $row) {
         $propIds[] = $row['proid'];
     }
     //从主表获取房源信息
     $propertyList = Model_House_HzProp::getPropsByPropIds($propIds);
     //获取是否精选或者竞价
     $relations = Model_Plan_HzPlanning::getBidRelationsByHouseIds($propIds, array(Const_HzPlan::SPREAD, Const_HzPlan::WAITING));
     if (!empty($relations)) {
         $planPropMap = array();
         foreach ($relations as $relation) {
             $planIds[] = $relation['plan_id'];
             $planPropMap[$relation['plan_id']] = $relation['proid'];
         }
         if (!empty($planIds)) {
             $plans = Model_Plan_HzPlanBasic::getPlansByIds($planIds);
             foreach ($plans as $plan) {
                 if ($plan->flag == 0) {
                     continue;
                 }
                 if ($plan->bid_version == 2) {
                     $propId = $planPropMap[$plan['id']];
                     $propertyList[$propId]['isChoice'] = 1;
                 } else {
                     $propId = $planPropMap[$plan['id']];
                     $propertyList[$propId]['isBid'] = 1;
                 }
             }
         }
     }
     // 批量获取房源的默认图片
     $defaultImages = Model_Image_HzImage::getDefaultImagesByHouseIds($propIds);
     if (!empty($defaultImages)) {
         foreach ($defaultImages as $defaultImage) {
             $propertyList[$defaultImage['proid']]['imgUrl'] = $defaultImage->imageUrl();
         }
     }
     krsort($propertyList);
     $startDate = $endDate = date('Ymd');
     $todayClicks = Bll_Combo_Broker_BrokerComboInfo::getHouseComboClickEx($propIds, $startDate, $endDate, Model_Ppc_NewPackageStatsHouseDay::SITE_TYPE_HZ);
     $totalClicks = Bll_House_HzHouse::getComboHouseAccumulateClick($ajkBrokerId, $propIds, $cityId);
     foreach ($propertyList as $list) {
         $row = array();
         $row['id'] = $list['propId'];
         $row['propId'] = $list['propId'];
         $row['title'] = $list['title'];
         $row['imgUrl'] = $list['imgUrl'] ?: '';
         $row['commId'] = $list['commid'];
         $row['commName'] = $list['commname'];
         $row['roomNum'] = $list['roomnum'];
         $row['hallNum'] = $list['hallnum'];
         $row['toiletNum'] = $list['toilnetnum'];
         $row['area'] = round($list['areanum']);
         $row['price'] = round($list['pricenum']);
         $row['priceUnit'] = '元/月';
         $row['todayClicks'] = $todayClicks[$list['propId']][$startDate] ?: 0;
         $row['totalClicks'] = $totalClicks[$list['propId']] ?: 0;
         $row['totalClicks'] = $row['totalClicks'] + $row['todayClicks'];
         $row['isBid'] = isset($list['isBid']) ? $list['isBid'] : 0;
         $row['isChoice'] = isset($list['isChoice']) ? $list['isChoice'] : 0;
         $row['isVisible'] = (int) ($list['status'] != 6);
         $row['isMoreImg'] = (int) $list['quality'];
         $row['isPhonePub'] = (int) (isset($list['from']) && $list['from'] == 'mobile-ajk-broker');
         $row['publishDays'] = floor((time() - $list['created']) / 86400);
         $row['publishDaysMsg'] = $row['publishDays'] > 0 ? "{$row['publishDays']}天前发布" : '今天发布';
         $row['createTime'] = date('Y-m-d H:i:s', $list['created']);
         //$row['updateTime'] = date('Y-m-d H:i:s', $list['updated']);
         //是否委托
         $isEntrust = Bll_Zufang_Choice::isCommissionHouse($list['propId'], $ajkBrokerId, Model_House_Commission::TYPE_RENT);
         $row['isEntrust'] = $isEntrust ? 1 : 0;
         $row['publishDays'] > 30 ? $oldList[] = $row : ($newList[] = $row);
     }
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('newList' => $newList, 'oldList' => $oldList, 'surplus' => $surplus - $currentSpreadHouseCount, 'hasCombo' => $hasCombo));
 }
예제 #20
0
 /**
  * 获取经纪人推广定价房源信息
  * @param $brokerId
  * @param int $planType
  * @param int $isValid
  * @return array
  */
 public function getBrokerHzFiexdProStatus($proIds)
 {
     return Model_Plan_HzPlanning::getBrokerPro($proIds);
 }
예제 #21
0
 public static function prepareChoiceList(&$out)
 {
     // $out['bidList'] = array();
     // $out['bidProIds'] = array();
     $out['choiceProIds'] = $out['choiceProps'] = $out['choiceComsume'] = array();
     // 目前需要获取精选房源id列表 供页面判断使用
     // 获取精选计划
     $validChoicePlans = Model_Plan_HzPlanBasic::getValidBidPlansEx($out['ajkBrokerId'], Const_HzPlan::BID_VERSION_CHOICE);
     if (empty($validChoicePlans)) {
         return;
     }
     $planIds = array();
     foreach ($validChoicePlans as $plan) {
         $planIds[] = $plan['id'];
     }
     // 获取关系
     $choicePlannings = Model_Plan_HzPlanning::getPlanningByPlanIds($planIds);
     if (empty($choicePlannings)) {
         return;
     }
     foreach ($choicePlannings as $choicePlanning) {
         $out['choiceProIds'][] = $choicePlanning['proid'];
         $out['choiceProps'][$choicePlanning['proid']]['choiceStatus'] = $choicePlanning['is_valid'];
         $out['choiceProps'][$choicePlanning['proid']]['planId'] = $choicePlanning['plan_id'];
     }
     // 获取精选消费信息
     //$out['choiceComsume'] = Bll_Plan_Bid_HzBid::getBidPlanConsumeAndClickInfos($planIds, date('Ymd'));
     $out['choiceComsume'] = Model_Stats_PropClick::getBillingInfo($out['hzBrokerId'], $out['cityId'], date('Ymd'));
 }
예제 #22
0
 /**
  * 获取计划单个房源关系
  *
  * @param int $userId
  * @param int $planId
  * @return array
  */
 public static function getOneHouseFixPlanRelation($userId, $planId)
 {
     try {
         return Model_Plan_HzPlanning::data_access()->filter('plan_id', $planId)->filter('plan_type', self::FIX_PLAN)->filter('user_id', $userId)->get_row();
     } catch (Exception $e) {
         return array();
     }
 }
 private function moveHzPPCFixPlanRelation($cityId, $hzBrokerId, $fixPlan)
 {
     $ajkBrokerId = Model_Broker_HzMapping::get_ajk_broker_id($hzBrokerId);
     if ($ajkBrokerId == 0) {
         $this->logMsg(sprintf('经纪人[%d - %d]没有获取到二手房经纪人ID。', $cityId, $hzBrokerId));
         return;
     }
     $fixPlanId = $fixPlan['id'];
     $fixPlanHouseRelationList = Model_Plan_HzPlanning::getHouseFixPlanRelation($hzBrokerId, $fixPlanId);
     if (empty($fixPlanHouseRelationList)) {
         $this->logMsg(sprintf('经纪人[%d - %d - %d - %d]没有获取到好租定价计划房源', $cityId, $ajkBrokerId, $hzBrokerId, $fixPlanId));
         return;
     }
     foreach ($fixPlanHouseRelationList as $fixPlanHouseRelation) {
         $comboHouseRelation = Bll_Combo_HouseRelation::getRelationByHouseId($fixPlanHouseRelation['proid'], Model_Combo_HouseRelation::SITE_TYPE_HZ);
         if (!empty($comboHouseRelation)) {
             if ($comboHouseRelation['state'] == Model_Combo_HouseRelation::ENUM_COMBO_EXPIRE) {
                 $this->logMsg(sprintf('房源[%d]的套餐关系存在id[%d],且state==205', $fixPlanHouseRelation['proid'], $comboHouseRelation['id']));
                 continue;
             }
             if (1 == Bll_Combo_HouseRelation::updateComboStatusById($comboHouseRelation['id'], Model_Combo_HouseRelation::ENUM_COMBO_EXPIRE, Model_Combo_HouseRelation::SITE_TYPE_HZ)) {
                 $this->logMsg(sprintf('房源[%d]的套餐关系存在id[%d],更新成功', $fixPlanHouseRelation['proid'], $comboHouseRelation['id']));
             } else {
                 $this->logMsg(sprintf('房源[%d]的套餐关系存在id[%d],更新失败', $fixPlanHouseRelation['proid'], $comboHouseRelation['id']));
             }
             continue;
         }
         $data = array('houseId' => $fixPlanHouseRelation['proid'], 'brokerId' => $ajkBrokerId, 'cityId' => $cityId, 'state' => Model_Combo_HouseRelation::ENUM_COMBO_EXPIRE, 'created' => $fixPlanHouseRelation['last_update']);
         if (1 == Model_Combo_HouseRelation::create($data, Model_Combo_HouseRelation::SITE_TYPE_HZ)->save()) {
             $this->logMsg(sprintf('房源[%d]转移成功', $fixPlanHouseRelation['proid']));
         } else {
             $this->logMsg(sprintf('房源[%d]转移失败', $fixPlanHouseRelation['proid']));
         }
     }
 }
예제 #24
0
 /**
  * 写房源日志,通知solr下架房源
  *
  * @param array $queue
  * @return array
  */
 public static function notifySolrUpDown($queue)
 {
     $propPlanning = Model_Plan_HzPlanning::getPropBidPlan($queue['proId']);
     if (empty($propPlanning)) {
         $queue['cityId'] = Model_Broker_AjkBrokerExtend::getCityIdByBrokerId($queue['brokerId']);
         return static::notifySolr($queue, Const_ProLogType::LOG_CHOICE_NOFITY_SOLR_DOWN, '没有获取到房源精选关系-下架');
     }
     $planId = $propPlanning['plan_id'];
     $planInfo = Model_Plan_HzPlanBasic::get_plan_by_id($planId);
     if (empty($planInfo)) {
         return static::notifySolr($queue, Const_ProLogType::LOG_CHOICE_NOFITY_SOLR_DOWN, '没有获取到房源精选计划-下架');
     }
     $queue['planId'] = $planId;
     $queue['cityId'] = $planInfo['cityId'];
     if ($planInfo['status'] == Const_HzPlan::SPREAD) {
         return static::notifySolr($queue, Const_ProLogType::LOG_CHOICE_NOFITY_SOLR_UP, '精选推广-上架');
     }
     return static::notifySolr($queue, Const_ProLogType::LOG_CHOICE_NOFITY_SOLR_DOWN, '精选推广-下架');
 }
예제 #25
0
 /**
  * 判断房源是否可以参加精选房源推广
  *
  * @param $ajkBrokerId
  * @param $cityId
  * @param $propId
  * @return array
  */
 public static function checkPropCanChoice($ajkBrokerId, $cityId, $propId)
 {
     $propSearch = Model_House_HzPropSearch::get_prop_by_prop_id($cityId, $propId);
     if (empty($propSearch)) {
         return self::buildReturn(Bll_Plan_Bid_Choice::BID_FAIL_OTHER, '房源不存在');
     }
     /** 判断房源是否是当前经纪人的房源 */
     if ($propSearch['ajkBrokerId'] != $ajkBrokerId) {
         return self::buildReturn(Bll_Plan_Bid_Choice::BID_FAIL_OTHER, '房源不存在(code:-10086)');
     }
     /** 判断是否是精选开放城市 */
     if (!Bll_City::isChoiceIndependentCity($cityId, Const_Site::HAOZU)) {
         /** 判断房源是否在套餐推广中 */
         if (!Bll_Combo_HouseRelation::getOnlineRelationByHouseId($propId, Bll_Combo_HouseRelation::SITE_TYPE_HZ)) {
             return array('err_no' => Bll_Plan_Bid_Choice::BID_FAIL_OTHER, 'err_msg' => '房源必须套餐推广才能参与精选推广');
         }
     }
     /** 判断房源是否多图 */
     if ($propSearch['islabel'] == 0) {
         return self::buildReturn(Bll_Plan_Bid_Choice::BID_FAIL_QUALITY_OR_NEW, '多图、新发15天房源才能参与精选推广');
     }
     /** 判断房源是否是在15天内发布的 */
     if (date('ymd', strtotime('-16 days')) > date('Ymd', $propSearch['created'])) {
         return self::buildReturn(Bll_Plan_Bid_Choice::BID_FAIL_QUALITY_OR_NEW, '多图、新发15天房源才能参与精选推广');
     }
     /** 判断房源是否已经在竞价计划中了 取master */
     $propBidInfo = Model_Plan_HzPlanning::getPropBidPlan($propId, true);
     if (!empty($propBidInfo)) {
         $planBasic = Model_Plan_HzPlanBasic::get_plan_by_id($propBidInfo['plan_id'], true);
         if ($planBasic['bid_version'] == Const_HzPlan::BID_VERSION_CHOICE && in_array($planBasic['status'], array(Const_HzPlan::SPREAD, Const_HzPlan::WAITING))) {
             return self::buildReturn(Bll_Plan_Bid_Choice::BID_FAIL_OTHER, '该房源已经处于精选状态,请先删除');
         }
     }
     return array('err_no' => 0, 'err_msg' => '');
 }
 /**
  * 查询房源的精选(竞价)信息
  *
  * @param $list
  * @return array
  */
 private function getProBidInfo($list)
 {
     static $_cache = array();
     if (isset($_cache[$list['id']])) {
         return $_cache[$list['id']];
     }
     $bidInfo = array();
     //根据房源去查询计划信息
     if ($list['siteType'] == 1) {
         //二手房
         $ajkBidInfo = Model_Plan_AjkPropspread::getAjkPropspreadByProId($list['houseId']);
         if (!empty($ajkBidInfo)) {
             $bidInfo['bidVersion'] = $ajkBidInfo['bidVersion'];
             $bidInfo['bidId'] = $ajkBidInfo['id'];
         }
     } elseif ($list['siteType'] == 2) {
         //租房
         $hzBidId = Model_Plan_HzPlanning::getPropBidPlan($list['houseId']);
         if (!empty($hzBidId)) {
             //查询计划信息
             $hzBidInfo = Model_Plan_HzPlanBasic::get_plan_by_id($hzBidId['plan_id']);
             if (!empty($hzBidInfo) && in_array($hzBidInfo['status'], array(Const_HzPlan::SPREAD, Const_HzPlan::AUTOOVER, Const_HzPlan::MENUOVER, Const_HzPlan::PAUSE, Const_HzPlan::AWAIT, Const_HzPlan::UPPERLIMIT, Const_HzPlan::ENDTIME, Const_HzPlan::WAITING)) || $hzBidInfo['flag'] != 1) {
                 $bidInfo['bidVersion'] = $hzBidInfo['bid_version'];
                 $bidInfo['bidId'] = $hzBidInfo['id'];
             }
         }
     } elseif ($list['siteType'] == 3) {
         //金铺
         $jpBidInfo = Model_Plan_Jp::getBidPlanByHouseIdV2($list['houseId']);
         if (!empty($jpBidInfo)) {
             $bidInfo['bidVersion'] = $jpBidInfo->bidVersion;
             $bidInfo['bidId'] = $jpBidInfo->id;
         }
     }
     $_cache[$list['id']] = $bidInfo;
     return $bidInfo;
 }
예제 #27
0
 /**
  * 获取经纪人有效定价关系
  * @param $hzBrokerId
  * @return array
  */
 public static function getValidPlannings($hzBrokerId)
 {
     return Model_Plan_HzPlanning::getBrokerProInfo($hzBrokerId, Const_HzPlan::SPREAD_TYPE, self::getValidStatus());
 }
예제 #28
0
 /**
  * 重新计算坑位数
  *  获取精选计划,根据计划的板块id、价格段id重新计算坑位信息。
  *  从房源信息里获取到新的板块id、价格段id,更新计划的板块id、价格段id,重新计算坑位信息.
  *
  * @param int $houseId
  * @param int $cityId
  * @return string
  */
 public static function rebuildBucketHz($houseId, $cityId)
 {
     $houseChoicePlan = Model_Plan_HzPlanning::getPropBidPlan($houseId);
     if (empty($houseChoicePlan)) {
         return '房源没有做精选';
     }
     $choicePlanInfo = Model_Plan_HzPlanBasic::get_plan_by_id($houseChoicePlan['plan_id']);
     if (empty($choicePlanInfo)) {
         return '没有获取到精选计划';
     }
     if ($choicePlanInfo['status'] != Const_HzPlan::SPREAD && $choicePlanInfo['status'] != Const_HzPlan::WAITING) {
         return '房源精选不在推广或排队中';
     }
     $propInfo = Model_House_HzProp::get_prop_info_by_prop_id($houseId);
     $blockId = $propInfo['contentBasic']['blockid'];
     $priceIntervalInfo = Model_House_HzPriceChoice::get_price($cityId, $propInfo['contentBasic']['pricenum']);
     if (empty($priceIntervalInfo)) {
         return '没有获取到价格段信息';
     }
     $priceId = $priceIntervalInfo['id'];
     $data = array('blockId' => $blockId, 'priceId' => $priceId);
     if (0 == Model_Plan_HzPlanBasic::updatePlan($houseChoicePlan['plan_id'], $data)) {
         return "更新精选计划[{$houseChoicePlan['plan_id']}]信息失败[{$blockId} - {$priceId}]";
     }
     $result = '';
     if (static::updateBucket($blockId, $priceId)) {
         $result .= "(新)更新坑位[{$blockId} - {$priceId}]成功";
     } else {
         $result .= "(新)更新坑位[{$blockId} - {$priceId}]失败";
     }
     if (static::updateBucket($choicePlanInfo['blockId'], $choicePlanInfo['priceId'])) {
         $result .= "(旧)更新坑位[{$choicePlanInfo['blockId']} - {$choicePlanInfo['priceId']}]成功";
     } else {
         $result .= "(旧)更新坑位[{$choicePlanInfo['blockId']} - {$choicePlanInfo['priceId']}]失败";
     }
     return $result;
 }
예제 #29
0
 /**
  * 增加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']}上线日志写入";
             }
         }
     }
 }
예제 #30
0
 /**
  * 205 计划限额变小(页面触发)
  * 计划id非空判断
  * 计划信息非空判断
  * 写入修改计划日志
  * 如果计划status!=1,return
  * 查询计划的当日话费
  * 如果话费>=当日限额 continue 如果话费< 当日限额 return
  * 如果计划正在推广,更新状态为status=2 计划上限
  * 查询房源计划关系
  *   如果不存在 return
  *   如果关系非手动停止或非账户余额不足,更新状态为is_valid=2
  *   记录房源第二天推广日志
  */
 private function low_plan_budget()
 {
     $planInfo = $this->checkPlanIsEmpty();
     $this->writePlanLog(2, '减少计划限额');
     if (!$planInfo['status'] != Const_HzPlan::SPREAD) {
         return;
     }
     // 判断计划今日话费和限额
     $today_cost = Bll_HzFixPlan::get_plan_clickinfo($this->params['broker_id'], $this->params['plan_id']);
     if ((int) $planInfo['amount'] > $today_cost['total_cost']) {
         return;
     }
     // 更新计划封顶2
     if (!Dao_Broker_HzPlan::update_plan_status($this->params['plan_id'], Const_HzPlan::AUTOOVER)) {
         throw new Exception_BllErrorException("更新计划为封顶2数据失败");
     }
     // 查询关系 并更新为余额不足 并记录第二天推广
     $plannings = Dao_Broker_HzPlan::get_planning($this->params['plan_id']);
     if (empty($plannings)) {
         return;
     }
     foreach ($plannings as $planning) {
         if (in_array($planning['is_valid'], array(Const_HzPlan::AUTOOVER, Const_HzPlan::UPPERLIMIT, Const_HzPlan::MANUALLY_PAUSE))) {
             continue;
         }
         // 更新关系
         if (!Model_Plan_HzPlanning::updatePropPlan($planning['id'], array('is_valid' => Const_HzPlan::AUTOOVER))) {
             throw new Exception_BllErrorException("更新关系为上限失败, 关系id:{$planning['id']}");
         }
         // 维护房子状态
         Bll_HzPropBll::bulidHzProStatu($planning['proid']);
         $this->params['pro_id'] = $planning['proid'];
         $this->writePropLog(7, '第二天推广');
     }
 }