Пример #1
0
 /**
  * 根据计划Id获取有效的推广信息
  */
 public static function getValidStaticPricePlanById($planId)
 {
     try {
         return Model_Plan_EsfFixedPlan::data_access()->filter('id', $planId)->filter('status', 1)->get_all();
     } catch (Exception $e) {
         return array();
     }
 }
Пример #2
0
 /**
  * 获取经纪人所有的定价计划
  * 由于目前PPC城市 都已经封顶了,所以每个经纪人都只有一个定价计划是有效的
  *
  * @param int $brokerId
  * @return array
  */
 public static function getBrokerPlanList($brokerId)
 {
     $datas = Model_Plan_EsfFixedPlan::getBrokerValidPlan($brokerId);
     $fixPlanInfos = array();
     foreach ($datas as $data) {
         $fixPlanInfos[$data['id']] = $data;
     }
     return $fixPlanInfos;
 }
Пример #3
0
 public function handle_request_internal()
 {
     //判断房源是否定价 拿propid去static_price_relation 查PlanId 再去static_price_plan表中查定价信息
     $propId = $this->_params['propId'];
     $cityId = $this->_params['cityId'];
     //好丑陋。。。。。。好无奈。。。。。。
     //委托房源自动转发停用,为了app能够展示报错信息。。。
     if (empty($propId)) {
         $this->_params['apiDebug'] = 1;
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => '0000', 'message' => '委托房源自动转发功能已停用;若要发布请手动发布');
     }
     $relation = Model_Plan_AjkFixRelation::getRelationByProId($propId, $cityId);
     $result['status'] = 'ok';
     $data['totalClicks'] = $data['todayClicks'] = $data['clickPrice'] = 0;
     $data['planId'] = '';
     if (!empty($relation)) {
         if ($relation['status'] == Model_Plan_AjkFixRelation::STATUS_NORMAL) {
             $data['status'] = 1;
             //房源在定价推广中
         } else {
             $data['status'] = 0;
             //未推广
         }
         $plan = Model_Plan_EsfFixedPlan::getValidStaticPricePlanById($relation['planId']);
         $data['planId'] = $plan[0]['id'];
         if (!empty($plan)) {
             //房源在定价推广中
             //房源点击量
             $proClickDao = new DAO_My_Ppc_PlanOpe();
             $proClickInfo = $proClickDao->getProClick($propId, strtotime("20120901"));
             if (!empty($proClickInfo)) {
                 if (isset($proClickInfo[$propId])) {
                     $data['totalClicks'] = $proClickInfo[$propId];
                 }
                 $data['todayClicks'] = $proClickInfo['todayClicks'];
             }
         }
     } else {
         $data['status'] = 0;
         //未推广
     }
     //获取点击单价
     $houseInfo = Bll_House_EsfHouse::getHouseBaseInfo($propId, $cityId);
     if (!empty($houseInfo)) {
         $proPriceInt = $houseInfo[0]['proPriceInt'];
         $priceArr = DAO_My_Ppc_UtilTool::getPriceInterval($cityId, $proPriceInt - 0.01);
         if (!empty($priceArr)) {
             $data['clickPrice'] = round($priceArr['price'], 2);
         }
     }
     $data['clickPriceUnit'] = '元';
     $result['data'] = $data;
     return $result;
 }
Пример #4
0
 public function handle_request_internal()
 {
     $brokerId = $this->_params["brokerId"];
     $planId = $this->_params["planId"];
     if (empty($planId)) {
         $planInfo = Model_Plan_EsfFixedPlan::getValidPlan($brokerId);
         $planId = $planInfo['id'];
     }
     $post = array('brokerId' => $brokerId, 'planId' => $planId, 'from' => APF::get_instance()->get_config('java_api_from'));
     $url = '/service-ppc/rest/ppc/restartPpc';
     $data = Util_CallAPI::get_data_from_java_api($url, $post);
     if ($data['data']['status'] === 'ok') {
         $ret = array('status' => 'ok', 'data' => array());
     } else {
         return Util_MobileAPI::error_tmp($data['data']['code'], $data['data']['info']);
     }
     return $ret;
 }
Пример #5
0
 public function handle_request_internal()
 {
     $brokerId = $this->_params["brokerId"];
     $planId = $this->_params["planId"];
     if (empty($planId) && !empty($brokerId)) {
         $planInfo = Model_Plan_EsfFixedPlan::getValidPlan($brokerId);
         $planId = $planInfo['id'];
     }
     $post = array('brokerId' => $brokerId, 'planId' => $planId, 'proIds' => $this->_params['propIds']);
     $api_url = '/service-ppc/rest/ppc/planAddProperty';
     $result = Util_CallAPI::get_data_from_java_api($api_url, $post);
     if ($result['data']['status'] == 'ok') {
         $return = array('status' => 'ok', 'data' => array());
     } else {
         $return = Util_MobileAPI::error(self::changeJavaAPICodeToSelfCode($result['data']['code']));
     }
     return $return;
 }
Пример #6
0
 public function handle_request_internal()
 {
     $brokerId = $this->_params['brokerId'];
     $plans = Model_Plan_EsfFixedPlan::getValidPlan($brokerId);
     $props = 0;
     $result['status'] = 'ok';
     if (!empty($plans)) {
         $planId = $plans['id'];
         $cityId = $plans['cityid'] ?: 0;
         $relations = Model_Plan_AjkFixRelation::getRelationListByPlanId($planId, $cityId);
         if (!empty($relations)) {
             $propIds = array();
             foreach ($relations as $row) {
                 $propIds[] = $row['proId'];
             }
             $houseInfo = Bll_House_EsfHouse::getHouseBaseInfo($propIds, $cityId);
             $props = count($houseInfo);
         }
         $planBll = new DAO_My_Ppc_PlanOpe();
         $clicks = $planBll->planTodayNewCost($planId);
         $data['planId'] = $planId;
         $data['todayClicks'] = $clicks['allclick'];
         $data['todayConsume'] = Util_Formatter::formatTodayConsume($clicks['allamount']);
         $data['todayConsumeUnit'] = '元';
         $data['totalProps'] = $props;
         //获取计划状态
         $api_url = '/service-ppc/rest/ppc/getPpcPlan/' . $planId . '?resType=1';
         $plan_info = Util_CallAPI::get_data_from_java_api($api_url);
         $data['planStatus'] = $plan_info['data']['plan']['statusDescrip'] == '推广中' ? 1 : 0;
         $limitInfo = Bll_Fixedspread_AjkFixedSpread::getLimitInfo($brokerId);
         $data['budget'] = !empty($limitInfo) ? round($limitInfo['amountLimit'] / 100, 2) : 0;
         $data['budgetUnit'] = '元';
     } else {
         $brokerInfo = Model_Broker_AjkBrokerExtend::getDataByBrokerId($brokerId);
         $planId = Model_Plan_EsfFixedPlan::addPlan('定价推广组', 1, $brokerInfo->cityId, $brokerInfo->userId, $brokerInfo->brokerId);
         $data['planId'] = $planId;
         $data['todayClicks'] = $data['todayConsume'] = $data['totalProps'] = $data['planStatus'] = 0;
         $data['todayConsumeUnit'] = $data['budgetUnit'] = '元';
         $limitInfo = Bll_Fixedspread_AjkFixedSpread::getLimitInfo($brokerId);
         $data['budget'] = !empty($limitInfo) ? round($limitInfo['amountLimit'] / 100, 2) : 0;
     }
     $result['data'] = $data;
     return $result;
 }
Пример #7
0
 /**
  * 通知solr处理
  *
  * <ol>
  * <li>
  * 当房源日志type为房源更新(4),房源推广(5),第二天推广(7)时,通知solr更新
  * </li>
  * <li>
  * 当房源日志type为房源删除(3),取消推广(6),取消第二天推广(12)时,通知solr删除
  * </li>
  * <li>
  * 通知solr的展示时间为job当时查到的计划的viewtime
  * </li>
  * </ol>
  */
 public function noticeSolrAjk($record)
 {
     $type = $record['type'];
     if ($type == 4 || $type == 5 || $type == 7) {
         $updateType = 1;
         //add
     } elseif ($type == 6 || $type == 12) {
         $updateType = 2;
         //delete
     } else {
         //记录处理日志
         $this->setLog('不需要做solr处理' . __METHOD__);
         return true;
     }
     $planId = $record['planId'];
     //获取计划的viewtime
     $planInfo = Model_Plan_EsfFixedPlan::data_access()->filter_by_op('id', '=', $planId)->find_only();
     if (empty($planInfo)) {
         //记录处理日志
         $this->setLog(sprintf('计划[%d]信息为空,不做solr处理', $planId));
         return true;
     }
     $resArr = Bll_Combo_NoticeSolrUpDown::noticePpcSolrAjkAPI($record['cityId'], $record['brokerId'], $record['houseId'], $updateType, $planInfo->viewtime, $planId, Bll_Combo_NoticeSolrUpDown::HLSFromPpcUpDown, strtotime($record['addDate']), date('Ymd', strtotime($record['addDate'])) . $record['id']);
     if ($resArr['status'] != 'ok') {
         $this->setLog(sprintf('计划[%d],solr处理失败 res:' . json_encode($resArr), $planId));
         return false;
     }
     $this->setLog(sprintf('计划[%d],solr处理成功 res:' . json_encode($resArr), $planId));
     return true;
 }
Пример #8
0
 /**
  * 获取定价推广中的房源
  *
  * @param int $cityId
  * @param int $brokerId
  * @return array
  */
 public static function getFixSpreadHouse($cityId, $brokerId)
 {
     $fixPlan = Model_Plan_EsfFixedPlan::getValidPlan($brokerId);
     if (empty($fixPlan)) {
         return array();
     }
     $planId = $fixPlan['id'];
     $fixPlanRelationList = Model_Plan_EsfPropFixedPlanRelation::getPropFixedPlanRelation($brokerId, $cityId, $planId);
     $houseIds = array();
     foreach ($fixPlanRelationList as $fixPlanRelation) {
         $houseIds[] = $fixPlanRelation['propId'];
     }
     return $houseIds;
 }
Пример #9
0
 /**
  * 通知solr处理
  *
  * <ol>
  * <li>
  * 当房源日志type为房源更新(4),房源推广(5)时,通知solr更新
  * </li>
  * <li>
  * 当房源日志type为取消推广(6),第二天推广(7),取消第二天推广(12)时,通知solr更新
  * </li>
  * <li>
  * 通知solr的展示时间为job当时查到的计划的viewtime
  * </li>
  * </ol>
  */
 public function noticeSolr($records)
 {
     foreach ($records as $row) {
         $type = $row->type;
         if ($type == 4 || $type == 5) {
             $solrType = 1;
             //add
         } elseif ($type == 6 || $type == 7 || $type == 12) {
             $solrType = 2;
             //delete
         } else {
             $this->addLogger('队列id' . $row->id . '房源id' . $row->houseId . '不需要做solr处理');
             continue;
         }
         $planId = $row->planId;
         //获取计划的viewtime
         $planInfo = Model_Plan_EsfFixedPlan::data_access()->filter_by_op('id', '=', $planId)->find_only();
         if (empty($planInfo)) {
             $this->addLogger('队列id' . $row->id . '计划' . $planId . '信息为空,不做solr处理');
             continue;
         }
         //curl参数
         $curlParam = array('city_id' => $row->cityId, 'broker_id' => $row->brokerId, 'pro_id' => $row->houseId, 'flag' => $solrType, 'hpstarttime' => $planInfo->viewtime, 'hpendtime' => 0, 'hpplanid' => $planId, 'update_time' => time());
         $curlJsonParam = json_encode($curlParam);
         //curl设置
         $connecttime = APF::get_instance()->get_config('JavaAPIConnectTime');
         if (empty($connecttime)) {
             $connecttime = 1;
         }
         $executetime = APF::get_instance()->get_config('JavaAPIExecuteTime');
         if (empty($executetime)) {
             $executetime = 1;
         }
         $this->curl->setDefaults();
         $this->curl->setConnectTimeOut($connecttime)->setTimeout($executetime);
         $url = "http://" . APF::get_instance()->get_config('UserMessageQueueHost') . "/publish?tunnel=esf_prop_pricing_updown";
         // 发起请求
         $this->curl->addOption(CURLOPT_POSTFIELDS, $curlJsonParam);
         $response = $this->curl->post($url);
         $response = json_decode($response, true);
         if (!$response || $response['status'] != 'ok') {
             $response = $this->curl->post($url);
             $response = json_decode($response, true);
         }
         if (!$response || $response['status'] != 'ok') {
             $this->addLogger('队列id' . $row->id . '房源id' . $row->houseId . 'solr处理失败');
         } else {
             $this->addLogger('队列id' . $row->id . '房源id' . $row->houseId . 'solr处理成功');
         }
         $curlLogmsg = json_encode(array('time' => date("Ymd H:i:s"), 'url' => $url, 'param' => $curlParam, 'result' => $response));
         $this->curlLog($curlLogmsg);
     }
 }
 private function getBrokerStaticPricePlanList($brokerId)
 {
     return Model_Plan_EsfFixedPlan::getValidStaticPricePlan($brokerId);
 }