示例#1
0
 public function handle_request_internal()
 {
     $brokerId = $this->_params['brokerId'];
     $planId = $this->_params['planId'];
     // 获取定价计划
     $fixPlan = Model_Plan_HzPlanBasic::getActivePlanById($planId);
     if (!$fixPlan) {
         throw new Exception('计划不存在', Const_APIStatus::E_PLAN_NOTFOUND);
     }
     // 暂停定价计划
     $hzBrokerId = Bll_HzBroker::get_brokerid_by_ajk_brokerid($brokerId);
     $result = Bll_HzFixPlan::option_fix_plan($hzBrokerId, $planId, "stop");
     if (!$result['status']) {
         switch ($result['msg']) {
             case Const_HzErrorInfo::PLANSTOPING:
                 throw new Exception('计划已经停止', Const_APIStatus::E_PLAN_ALREADY_STOPPED);
                 break;
             default:
                 return Util_MobileAPI::error(Const_APIStatus::E_PLAN_PARAM_ERR);
         }
     }
     // 记录定价上下架日志
     $result = Bll_ProPlanChangeApiBll::get_instance()->insertProPlanChange(array('broker_id' => $brokerId, 'plan_id' => $planId, 'type' => 'plan_stop', 'from' => 'Mobile API v1: ' . __CLASS__, 'remark' => json_encode(array('fix' => array('plan_status' => $fixPlan['status']))), 'site_type' => 2), $brokerId);
     if ($result['status'] != 'ok') {
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => Const_APIStatus::E_SYS_ERR, 'message' => $result['msg']);
     }
     return array('status' => 'ok', 'data' => array());
 }
示例#2
0
 public function get_plan($planId)
 {
     $da = Model_Plan_HzPlanBasic::data_access();
     $da->filter('id', $planId);
     $da->filter('flag', 1);
     $data = $da->find();
     return $data;
 }
 public function handle_request()
 {
     $currentTableSplitSuffix = date('m');
     $failedActionQueue = Model_Choice_ActionQueue::getFailedAbandonFee($this->queueId, Model_Choice_ActionQueue::ENUM_HAOZU, $this->tableSplitSuffix);
     if (empty($failedActionQueue)) {
         /** 如果不是同一个月的话,那么前一个月没有需要修复的数据就开始修复本月的数据 */
         if (strcmp($currentTableSplitSuffix, $this->tableSplitSuffix) != 0) {
             $this->saveCursor($currentTableSplitSuffix, 0);
         }
         return;
     }
     $this->log("开始修复: ID={$failedActionQueue['id']}\tBrokerId={$failedActionQueue['brokerId']}\tPlanId={$failedActionQueue['planId']}\tupdateRemark={$failedActionQueue['updateRemark']}");
     $ajkBrokerExtend = Model_Broker_AjkBrokerExtend::getDataByBrokerId($failedActionQueue['brokerId']);
     /** TODO 添加获取二手房经纪人信息为空日志 */
     if (empty($ajkBrokerExtend)) {
         $this->log(sprintf('    获取经纪人(%d)的UserId失败(%d)。', $failedActionQueue['brokerId'], $failedActionQueue['id']));
         $this->saveCursor($this->tableSplitSuffix, $failedActionQueue['id']);
         return;
     }
     $planExtend = Dao_Broker_HzPlan::get_bid_sn($failedActionQueue['planId']);
     /** TODO 添加获取SN 失败日志 */
     if (empty($planExtend)) {
         $this->log(sprintf('    获取计划(%d)的SN失败(%d)。', $failedActionQueue['planId'], $failedActionQueue['id']));
         $this->saveCursor($this->tableSplitSuffix, $failedActionQueue['id']);
         return;
     }
     // $planInfo = Dao_Broker_HzPlan::get_plan($failedActionQueue['planId']);
     $planInfo = Model_Plan_HzPlanBasic::get_plan_by_id($failedActionQueue['planId']);
     /** TODO 添加获取计划信息失败日志*/
     if (empty($planInfo)) {
         $this->log(sprintf('    获取计划(%d)的信息失败(%d)。', $failedActionQueue['planId'], $failedActionQueue['id']));
         $this->saveCursor($this->tableSplitSuffix, $failedActionQueue['id']);
         return;
     }
     //精选结算
     $amount = $planInfo['total_consume'];
     $note = '%E8%A7%A3%E5%86%BB';
     $this->log("    传递的参数:UserId={$ajkBrokerExtend['userId']}\tamount={$amount}\tplanId={$failedActionQueue['planId']}\tSN={$planExtend['sn']}");
     $unlockSuccess = Bll_PayAccount::cancel_frozen($ajkBrokerExtend['userId'], $amount, $failedActionQueue['planId'], Const_PaymentApp::HZ_CHOICE, $planExtend['sn'], $note, true);
     if ($unlockSuccess === true) {
         $this->log('    解冻成功。');
         $this->saveCursor($this->tableSplitSuffix, $failedActionQueue['id']);
         $repairRemark = $failedActionQueue['updateRemark'] . ', 解冻修复成功';
         /** 更新队列状态为处理成功 */
         Model_Choice_ActionQueue::setBidQueenStatusById($this->tableSplitSuffix, $failedActionQueue['id'], Model_Choice_ActionQueue::ENUM_SUCCESS, $repairRemark);
         return;
     }
     $this->log('    解冻失败。');
 }
 /**
  * 获取经纪人精选推广的房源Id
  *
  * @param int $brokerId
  * @return array
  */
 private function getHouseSpreadStateResultHz($brokerId)
 {
     $result = array('spread_house' => array(), 'not_spread_house' => array());
     /** 获取状态发生变更的计划Id */
     try {
         $dataAccess = Model_Plan_HzPlanBasic::data_access('');
         $dataAccess->filter('ajkBrokerId', $brokerId);
         $dataAccess->filter('status', Const_HzPlan::SPREAD);
         $dataAccess->filter('plan_type', 2);
         $dataAccess->filter('flag', 1);
         $dataAccess->load_field(array('id', 'status', 'ajkBrokerId'));
         $houseSpreadPlanList = $dataAccess->get_all();
     } catch (Exception $e) {
         return $result;
     }
     if (empty($houseSpreadPlanList)) {
         return $result;
     }
     $spreadPlanIds = array();
     foreach ($houseSpreadPlanList as $houseSpreadPlan) {
         if ($houseSpreadPlan['status'] == 1) {
             $spreadPlanIds[] = $houseSpreadPlan['id'];
         }
     }
     /** 获取房源Id */
     try {
         $dataAccess = Model_Plan_HzPlanning::data_access('');
         $dataAccess->filter('plan_id', $spreadPlanIds);
         $dataAccess->filter('plan_type', Model_Plan_HzPlanning::BID_OR_CHOICE_PLAN);
         $dataAccess->load_field(array('plan_id', 'proid'));
         $promotionPropPlanningList = $dataAccess->get_all();
     } catch (Exception $e) {
         return $result;
     }
     if (empty($promotionPropPlanningList)) {
         return $result;
     }
     foreach ($promotionPropPlanningList as $promotionPropPlanning) {
         if (in_array($promotionPropPlanning['plan_id'], $spreadPlanIds)) {
             $result['spread_house'][] = $promotionPropPlanning['proid'];
         }
     }
     return $result;
 }
示例#5
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));
     }
 }
 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 思考是否要修复 坑位表 */
     }
 }
示例#7
0
 public function handle_request_internal()
 {
     $brokerId = $this->_params['brokerId'];
     $propIds = $this->_params['propId'];
     $propIds = explode(',', $propIds);
     $planId = $this->_params['planId'];
     // 获取定价计划
     $fixPlan = Model_Plan_HzPlanBasic::getActivePlanById($planId);
     if (!$fixPlan) {
         throw new Exception('计划不存在', Const_APIStatus::E_PLAN_NOTFOUND);
     }
     // 批量取消房源定价推广
     $hzBrokerId = Bll_HzBroker::get_brokerid_by_ajk_brokerid($brokerId);
     $result = Bll_HzFixPlan::batchprop_out_fix($hzBrokerId, $propIds, $planId);
     if (!$result['status']) {
         return Util_MobileAPI::error(Const_APIStatus::E_PLAN_PARAM_ERR);
     }
     return array('status' => 'ok', 'data' => array());
 }
 /**
  * 修复竞价计划没有解冻
  */
 public function repairPlanDeduct()
 {
     $planIds = array(823960, 829941, 832069, 832072, 832092, 832094, 836322, 836323, 839239, 839247);
     $note = urlencode('解冻');
     foreach ($planIds as $planId) {
         $this->log(sprintf('开始修复计划%d.....', $planId));
         $planInfo = Model_Plan_HzPlanBasic::get_plan_by_id($planId);
         $hzBrokerId = $planInfo['user_id'];
         $userId = Bll_HzBroker::get_userid_by_hzbrokerid($hzBrokerId);
         $planExtend = Dao_Broker_HzPlan::get_bid_sn($planId);
         $amount = $planInfo['total_consume'];
         $this->log("传递的参数:UserId={$userId}\tamount={$amount}\tplanId={$planId}\tSN={$planExtend['sn']}");
         $charge_sn = Bll_PayAccount::cancel_frozen($userId, $amount, $planId, Const_PaymentApp::HZ_BID, $planExtend['sn'], $note, true);
         if ($charge_sn['data']['status'] === 'ok') {
             $this->log('修复成功。');
         } else {
             $this->log('修复失败。');
         }
     }
 }
示例#9
0
 public function handle_request()
 {
     $brokers = array();
     $dao = Model_Plan_HzPlanBasic::data_access();
     if ($this->brokerid) {
         $insql = 'a.user_id=? and ';
         $params = array($this->brokerid, $this->cityid);
     } else {
         $insql = '';
         $params = array($this->cityid);
     }
     $datas = $dao->native_sql('SELECT DISTINCT(a.user_id) AS user_id FROM rent_db.promotion_planning_basic AS a LEFT JOIN rent_db.promotion_prop_planning AS b  ON a.id=b.plan_id WHERE ' . $insql . ' b.`city_id`=? AND a.plan_type=2 AND a.`status`=1 AND b.is_valid=1;', $params);
     foreach ($datas as $data) {
         $brokerid = $data['user_id'];
         if (isset($brokers[$brokerid])) {
             continue;
         }
         $result = Uri_Curl::get($this->url . 'zufang/api/broker/transformmoney', array('userid' => $brokerid, 'status' => 5));
         printf('[%s]开始处理租房: brokerId为 %s,处理结果:%s' . PHP_EOL, date('Y-m-d H:i:s'), $brokerid, $result);
         $brokers[$brokerid] = 1;
     }
 }
示例#10
0
 public function handle_request_internal()
 {
     $brokerId = $this->_params['brokerId'];
     $planId = $this->_params['planId'];
     // 获取定价计划
     $fixPlan = Model_Plan_HzPlanBasic::getActivePlanById($planId);
     if (!$fixPlan) {
         throw new Exception('计划不存在', Const_APIStatus::E_PLAN_NOTFOUND);
     }
     // 开启定价计划
     $hzBrokerId = Bll_HzBroker::get_brokerid_by_ajk_brokerid($brokerId);
     $result = Bll_HzFixPlan::option_fix_plan($hzBrokerId, $planId, "repeat");
     if (!$result['status']) {
         switch ($result['msg']) {
             case Const_HzErrorInfo::PLANFIXING:
                 throw new Exception('计划已经开启', Const_APIStatus::E_PLAN_ALREADY_STARTED);
                 break;
             case Const_HzErrorInfo::BROKERCHECK:
                 throw new Exception('您的身份认证未通过审核,请联系你的客户经理', Const_APIStatus::E_BROKER_ISNOT_VERFIYED);
                 break;
             case Const_HzErrorInfo::PLANMONEY:
                 throw new Exception('账户余额不足,请充值后操作', Const_APIStatus::E_BROKER_NO_MONEY);
                 break;
             case Const_HzErrorInfo::PLANAMOUNT:
                 throw new Exception('今日限额已经用完,请调整限额后操作', Const_APIStatus::E_PLAN_ERR_3013);
                 break;
             default:
                 return Util_MobileAPI::error(Const_APIStatus::E_PLAN_PARAM_ERR);
         }
     }
     // 记录定价上下架日志
     $result = Bll_ProPlanChangeApiBll::get_instance()->insertProPlanChange(array('broker_id' => $brokerId, 'plan_id' => $planId, 'type' => 'plan_start', 'from' => 'Mobile API v1: ' . __CLASS__, 'remark' => json_encode(array('fix' => array('plan_status' => $fixPlan['status']))), 'site_type' => 2), $brokerId);
     if ($result['status'] != 'ok') {
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => Const_APIStatus::E_SYS_ERR, 'message' => $result['msg']);
     }
     return array('status' => 'ok', 'data' => array());
 }
 /**
  * Job执行逻辑
  */
 public function handle_request()
 {
     printf('[%s] lastLogId: %s' . PHP_EOL, date('Y-m-d H:i:s'), $this->lastLogId);
     // 获取任务
     $tasks = Model_Plan_HzPlanBasic::data_access()->filter('plan_type', Const_HzPlan::BID_TYPE)->filter('status', 1)->filter('flag', 1)->filter('bid_version', Const_HzPlan::BID_VERSION_CHOICE)->filter_by_op('id', '>', $this->lastLogId)->limit($this->limit)->get_all();
     if ($tasks === false) {
         printf('[%s] remark: %s' . PHP_EOL, date('Y-m-d H:i:s'), '获取数据失败');
         exit;
     }
     if (empty($tasks)) {
         // 任务完成
         printf('[%s] remark: %s' . PHP_EOL, date('Y-m-d H:i:s'), '任务执行完成');
         $this->setStop();
         $this->setShStopFlag();
         exit;
     }
     // 循环处理任务
     foreach ($tasks as $task) {
         $this->dealTask($task);
         $this->lastLogId = $task['id'];
     }
     //记录游标
     $this->setFlag(array('lastLogId' => $this->lastLogId));
 }
示例#12
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;
 }
示例#13
0
 /**
  * 获取计划的排队位置
  *
  * @param $planId
  * @param $cityId
  * @param $blockId
  * @param $housePriceId
  * @return int
  */
 public static function getChoiceWaitPosition($planId, $cityId, $blockId, $housePriceId)
 {
     $planList = Model_Plan_HzPlanBasic::getChoiceWaitPlan($blockId, $housePriceId);
     $index = 1;
     foreach ($planList as $plan) {
         if ($plan['id'] == $planId) {
             return $index;
         }
         $index++;
     }
     return $index;
 }
示例#14
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;
 }
示例#15
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;
 }
示例#16
0
 /**
  * 根据经纪人ID和PlanId获取精选计划
  *
  * @param $ajkBrokerId
  * @param $planId
  * @return array|mixed|null
  */
 public static function getChoiceByBrokerIdAndPlanIdEx($ajkBrokerId, $planId)
 {
     try {
         $oPlanBasic = Model_Plan_HzPlanBasic::data_access()->filter('plan_id', $planId)->filter('ajkBrokerId', $ajkBrokerId)->filter('bid_version', Const_HzPlan::BID_VERSION_CHOICE)->find_only();
         return $oPlanBasic;
     } catch (Exception $e) {
         return array();
     }
 }
示例#17
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;
 }
示例#18
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;
 }
 /**
  * 查询房源的精选(竞价)信息
  *
  * @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;
 }
示例#20
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));
 }
示例#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 $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;
 }
示例#23
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' => '');
 }
示例#24
0
 /**
  * 获取所有排队中的精选计划
  *
  * @param int $startTime
  * @return array
  */
 public static function getAllChoiceWaitPlan($startTime)
 {
     try {
         return Model_Plan_HzPlanBasic::data_access()->filter('status', Const_HzPlan::WAITING)->filter('flag', 1)->filter('bid_version', Const_HzPlan::BID_VERSION_CHOICE)->filter('plan_type', Const_HzPlan::BID_TYPE)->filter_by_op('created', '>=', $startTime)->filter_by_op('created', '<', max(time() - 60, $startTime))->get_all();
     } catch (Exception $e) {
         return array();
     }
 }
示例#25
0
 /**
  * 手动暂停经纪人的定价计划
  *
  * @param int $planId
  * @return bool
  */
 public static function stopPlanByHand($planId)
 {
     return Model_Plan_HzPlanBasic::stopFixPlanByHand($planId);
 }
示例#26
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));
 }
示例#27
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, '精选推广-下架');
 }
示例#28
0
 /**
  * 根据经纪人获取有效计划
  * @param $hzBrokerId
  * @return array
  */
 public static function getValidPlansByBrokerId($hzBrokerId)
 {
     return Model_Plan_HzPlanBasic::getPlanByCondition($hzBrokerId, array('plan_type' => Const_HzPlan::SPREAD_TYPE, 'status' => Bll_Plan_Fix_HzFix::getValidStatus()));
 }
 /**
  * 获取定价计划列表
  *
  * @return array
  */
 private function getHzFixPlanList()
 {
     $condition = array(array('plan_type', '=', Const_HzPlan::SPREAD_TYPE), array('id', '>', $this->_startId), array('user_id', '>', 0), array('flag', '=', 1), array('cityId', '=', $this->_cityId), array('status', 'in', array(Const_HzPlan::SPREAD, Const_HzPlan::AUTOOVER, Const_HzPlan::AWAIT, Const_HzPlan::UPPERLIMIT, Const_HzPlan::MANUALLY_PAUSE)));
     return Model_Plan_HzPlanBasic::getPlanLists($condition, self::PLAN_LIMIT);
 }
示例#30
0
 public function getComboPropsInOneComm($brokerId, $cityId, $commId = '')
 {
     $siteType = Bll_Combo_Broker_BrokerComboInfo::SITE_TYPE_HZ;
     $comboList = Bll_Combo_HouseRelation::getHouseRelations($brokerId, $siteType, 1);
     if (empty($comboList)) {
         return array();
     }
     $propIds = array();
     foreach ($comboList as $row) {
         $propIds[] = $row['houseId'];
     }
     $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);
     $base_domain = APF::get_instance()->get_config('base_domain');
     $startDate = $endDate = date('Ymd');
     $todayClicks = Bll_Combo_Broker_BrokerComboInfo::getHouseComboClickEx($propIds, $startDate, $endDate, Model_Ppc_NewPackageStatsHouseDay::SITE_TYPE_HZ);
     $totalClicks = Bll_House_HzHouse::getComboHouseAccumulateClick($brokerId, $propIds, $cityId);
     foreach ($propertyList as $key => $prop) {
         if (in_array($prop['status'], array(Const_HzStatus::VERIFY, Const_HzStatus::REMOVE, Const_HzStatus::EXPIRED))) {
             continue;
         }
         $row = array();
         $row['id'] = $prop['propId'];
         $row['title'] = $prop['title'];
         $row['commId'] = $prop['commid'];
         $row['commName'] = $prop['commname'];
         $row['roomNum'] = $prop['roomnum'];
         $row['hallNum'] = $prop['hallnum'];
         $row['toiletNum'] = $prop['toilnetnum'];
         $row['area'] = round($prop['areanum']);
         $row['price'] = round($prop['pricenum']);
         $row['priceUnit'] = '元/月';
         $row['isVisible'] = (int) ($prop['status'] != 6);
         $row['imgUrl'] = $prop['imgUrl'] ?: '';
         $row['isMoreImg'] = (int) $prop['quality'];
         $row['isPhonePub'] = (int) (isset($prop['from']) && $prop['from'] == 'mobile-ajk-broker');
         $row['propUrl'] = 'http://' . $base_domain . '/web/rent/x/' . $prop['cityid'] . '/' . $prop['propId'] . '-3';
         $row['isBid'] = isset($prop['isBid']) ? $prop['isBid'] : 0;
         $row['isChoice'] = isset($prop['isChoice']) ? $prop['isChoice'] : 0;
         $todayClick = $todayClicks[$prop['propId']][$startDate] ?: 0;
         $row['totalClicks'] = $totalClicks[$prop['propId']] ?: 0;
         $row['totalClicks'] = $row['totalClicks'] + $todayClick;
         $row['createTime'] = date('Y-m-d H:i:s', $prop['created']);
         $row['updateTime'] = date('Y-m-d H:i:s', $prop['updated']);
         $commProps[$prop['commid']][$key] = $row;
     }
     // 如果是获取某单个小区房源列表
     if ($commId) {
         $ret['status'] = 'ok';
         $ret['data']['propertyList'] = isset($commProps[$commId]) && !empty($commProps[$commId]) ? array_values($commProps[$commId]) : array();
     } else {
         $ret = isset($commProps) && !empty($commProps) ? $commProps : array();
     }
     return $ret;
 }