Exemplo n.º 1
0
 /**
  * 判断经纪人是否可以添加房源精选订阅
  *
  * 1. 是否已精选房源
  * 2. 是否已设提醒房源
  * 3. 是否具有精选资格房源:定价,多图,新发15天
  * 4. 是否推广位已满
  */
 protected function hasAddChoiceRemindPermission()
 {
     // 是否已精选
     $bllChoice = new Bll_Zufang_Choice();
     $planInfo = $bllChoice->get_plan_by_proid($this->propId);
     if (!empty($planInfo)) {
         $planId = $planInfo->plan_id;
         $basicPlanInfo = $bllChoice->get_plan($planId);
         if ($basicPlanInfo[0]->status == 1 || $basicPlanInfo[0]->status == 13) {
             return array('code' => '', 'msg' => '房源已精选');
         }
     }
     // 是否已订阅
     $subscription = Model_Choice_Subscription::data_access()->filter('site', Model_Choice_Subscription::SITE_RENT)->filter('propId', $this->propId)->filter('bucketId', $this->bucket['id'])->find_only();
     if ($subscription && $subscription['status'] == Model_Choice_Subscription::SUBSCRIPTION_START) {
         return array('code' => '', 'msg' => '推广位已订阅');
     }
     // 是否可精选
     // - 是否已定价/套餐
     // - 是否多图
     // - 是否新发15天
     //套餐经纪人 还是ppc经纪人
     /*$IsComboBroker = Bll_Broker_HzBroker::isComboBroker($this->brokerId);
       if ($IsComboBroker) {
           //是否套餐推广
           $comboHouseRelation = Model_Combo_HouseRelation::getOnlineHousebyHouseId($this->brokerId, $this->propId, $this->broker['cityId'], Model_Combo_HouseRelation::SITE_TYPE_HZ);
           if(empty($comboHouseRelation)) {
               return array(
                   'code' => '', // TODO
                   'msg' => '不满足精选推广添加:套餐推广',
               );
           }
       } else {
           //PPC经纪人 判定定价计划
           $fixPlan = $this->prop->getFixPlan();
           if(empty($fixPlan)) {
               return array(
                   'code' => '', // TODO
                   'msg' => '不满足精选推广添加:定价推广',
               );
           }
       }*/
     if (!Bll_City::isChoiceIndependentCity($this->broker['cityId'], Const_Site::ANJUKE)) {
         //是否套餐推广
         $comboHouseRelation = Model_Combo_HouseRelation::getOnlineHousebyHouseId($this->brokerId, $this->propId, $this->broker['cityId'], Model_Combo_HouseRelation::SITE_TYPE_HZ);
         if (empty($comboHouseRelation)) {
             return array('code' => '', 'msg' => '不满足精选推广添加:套餐推广');
         }
     }
     if (!($this->prop->isMultiImages() && $this->prop->getPublishedDays() <= 15)) {
         return array('code' => '', 'msg' => '不满足精选推广添加:多图,新发15天');
     }
     // 是否推广位已满
     if (!($this->bucket['usedNum'] >= $this->bucket['totalNum'])) {
         return array('code' => '', 'msg' => '推广位未满');
     }
     return true;
 }
Exemplo n.º 2
0
 public function handle_request_internal()
 {
     $brokerId = $this->_params['brokerId'];
     $houseId = $this->_params['propId'];
     $brokerInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId);
     if (!$brokerInfo) {
         throw new Exception_BrokerNotFoundException('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS);
     }
     $cityId = $brokerInfo->cityId;
     $isDisplaySummary = 0;
     if (!Bll_City::isChoiceCity($cityId, Const_Site::HAOZU)) {
         $data = array('totalClicks' => 0, 'balance' => 0, 'balanceUnit' => '元', 'todayClicks' => 0, 'todayConsume' => 0, 'todayConsumeUnit' => '元', 'clickPrice' => 0, 'clickPriceUnit' => '元', 'maxBucketNum' => 0, 'usedBucketNum' => 0, 'bucketId' => '', 'status' => bll_choice_EsfAPPAPIChoice::PROP_ACTIONTYPE_CHOICE_NOTFIT, 'statusMsg' => '你所在城市未开通精选业务', 'remindStatus' => -1, 'remindStatusMsg' => '不符合精选订阅条件', 'minChoicePrice' => 0, 'minChoicePriceUnit' => '元', 'maxChoicePrice' => 0, 'maxChoicePriceUnit' => '元', 'isDisplaySummary' => $isDisplaySummary);
         return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => $data);
     }
     $isDisplaySummary = 1;
     //获取该房子的精选计划
     $bllChoice = new Bll_Zufang_Choice();
     $planInfo = $bllChoice->get_plan_by_proid($houseId);
     $amount = 0;
     $totalConsume = 0;
     if ($planInfo) {
         $planId = $planInfo->plan_id;
         $planBasicInfo = $bllChoice->get_plan($planId);
         $amount = $planBasicInfo[0]->amount;
         $totalConsume = $planBasicInfo[0]->total_consume;
     }
     //获取 blockId, priceId
     $propInfo = $bllChoice->get_prop_content($houseId);
     if (empty($propInfo)) {
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => '', 'message' => '房源不存在');
     }
     $content = json_decode($propInfo[0]->contentBasic, true);
     $price = intval($content['pricenum']);
     $blockId = $content['blockid'];
     $priceInfo = Bll_Choice_HzBidBucket::getPriceIntervalInfo($cityId, $price);
     $priceId = $priceInfo['id'];
     //获取坑位信息
     $bucketInfo = Bll_Choice_HzBidBucket::getBucketInfo($blockId, $priceId);
     // 获取点击单价
     try {
         $clickPriceInfo = Bll_Service_Choice::hzClickPrice(array('cityId' => $cityId, 'price' => (int) $price, 'blockId' => $blockId, 'brokerId' => $brokerId));
         if ($clickPriceInfo['status'] == 'error') {
             return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => '', 'message' => '系统繁忙(code:-33)');
         }
     } catch (Exception $e) {
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => '', 'message' => '系统繁忙(code:-33)');
     }
     $clickPrice = $clickPriceInfo['realTradeAmount'] / 100;
     $remindStatus = -1;
     // -1 不符合精选订阅条件
     $remindStatusMsg = '不符合精选订阅条件';
     if ($planInfo && $planInfo->is_valid == 1) {
         $date = date('Ymd');
         $propChoice = $bllChoice->get_prop_choice_info($houseId, $date, $cityId);
         $todayClicks = intval($propChoice[0]['bidClicks']);
         $todayConsume = intval($propChoice[0]['bidConsume']) / 100;
         $totalClicksInfo = $bllChoice->get_prop_choice_clicks($houseId, $cityId);
         $totalClicks = intval($totalClicksInfo[0]['bidClicks']);
         $balance = $amount - $totalConsume;
         return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('todayClicks' => $todayClicks, 'todayConsume' => round($todayConsume, 2), 'todayConsumeUnit' => '元', 'totalClicks' => $totalClicks, 'balance' => round($balance, 2), 'balanceUnit' => '元', 'clickPrice' => round($clickPrice, 2), 'clickPriceUnit' => '元', 'maxBucketNum' => 20, 'usedBucketNum' => $bucketInfo['usedNum'], 'minChoicePrice' => 20, 'minChoicePriceUnit' => '元', 'maxChoicePrice' => 50, 'maxChoicePriceUnit' => '元', 'status' => '1-1', 'statusMsg' => '推广中', 'remindStatus' => $remindStatus, 'remindStatusMsg' => $remindStatusMsg, 'isDisplaySummary' => $isDisplaySummary));
     } else {
         if ($planInfo && $planInfo->is_valid == 13) {
             $totalClicksInfo = $bllChoice->get_prop_choice_clicks($houseId, $cityId);
             $totalClicks = intval($totalClicksInfo[0]['bidClicks']);
             $rank = Bll_Plan_Bid_HzBid::getChoiceWaitPosition($planInfo->plan_id, $cityId, $blockId, $priceId);
             return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('clickPrice' => round($clickPrice, 2), 'clickPriceUnit' => '元', 'totalClicks' => $totalClicks, 'balance' => round($amount, 2), 'balanceUnit' => '元', 'maxBucketNum' => 20, 'usedBucketNum' => $bucketInfo['usedNum'], 'minChoicePrice' => 20, 'minChoicePriceUnit' => '元', 'maxChoicePrice' => 50, 'maxChoicePriceUnit' => '元', 'status' => '1-2', 'statusMsg' => "{$rank}", 'remindStatus' => $remindStatus, 'remindStatusMsg' => $remindStatusMsg, 'isDisplaySummary' => $isDisplaySummary));
         } else {
             //判断是否符合精选条件 多图 + 新发15天
             if (false == $content['quality'] || date('Ymd', strtotime('-16 days')) > date('Ymd', $content['created'])) {
                 return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('clickPrice' => round($clickPrice, 2), 'clickPriceUnit' => '元', 'maxBucketNum' => 20, 'usedBucketNum' => $bucketInfo['usedNum'], 'minChoicePrice' => 20, 'minChoicePriceUnit' => '元', 'maxChoicePrice' => 50, 'maxChoicePriceUnit' => '元', 'status' => '3-2', 'statusMsg' => '精选推广条件:多图+新发15天', 'remindStatus' => $remindStatus, 'remindStatusMsg' => $remindStatusMsg, 'isDisplaySummary' => $isDisplaySummary));
             }
         }
     }
     if ($bucketInfo['usedNum'] >= $bucketInfo['totalNum']) {
         $status = '2-1';
         $statusMsg = '推广位已满';
     } else {
         if ($bucketInfo['usedNum'] >= $bucketInfo['maxOnlineNum']) {
             $status = '2-2';
             $statusMsg = '可立即排队';
         } else {
             $status = '2-3';
             $statusMsg = '可立即推广';
         }
     }
     // 如果推广位已满,判断推广位是否已订阅
     if ($status == '2-1') {
         $subscription = Model_Choice_Subscription::data_access()->filter('site', Model_Choice_Subscription::SITE_RENT)->filter('brokerId', $brokerId)->filter('propId', $houseId)->filter('bucketId', $bucketInfo['id'])->filter('status', Model_Choice_Subscription::SUBSCRIPTION_START)->find_only();
         if ($subscription) {
             $remindStatus = 1;
             // 1 已订阅
             $remindStatusMsg = '取消推广位提醒';
         } else {
             $remindStatus = 0;
             // 0 未订阅
             $remindStatusMsg = '有推广位了提醒我';
         }
     }
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('clickPrice' => round($clickPrice, 2), 'clickPriceUnit' => '元', 'bucketId' => $bucketInfo['id'], 'maxBucketNum' => $bucketInfo['totalNum'], 'usedBucketNum' => $bucketInfo['usedNum'], 'minChoicePrice' => 20, 'minChoicePriceUnit' => '元', 'maxChoicePrice' => 50, 'maxChoicePriceUnit' => '元', 'status' => $status, 'statusMsg' => $statusMsg, 'remindStatus' => $remindStatus, 'remindStatusMsg' => $remindStatusMsg, 'isDisplaySummary' => $isDisplaySummary));
 }
Exemplo n.º 3
0
 public function handle_request_internal()
 {
     $brokerId = $this->_params['brokerId'];
     $houseId = $this->_params['propId'];
     $budget = $this->_params['budget'];
     if ($budget < 20 || $budget > 50) {
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => '', 'message' => '请输入20~50之间的整数');
     }
     $brokerInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId);
     if (!$brokerInfo) {
         throw new Exception_BrokerNotFoundException('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS);
     }
     $cityId = $brokerInfo->cityId;
     if (!Bll_City::isChoiceCity($cityId, Const_Site::HAOZU)) {
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => Const_APIStatus::E_NOT_CHOICE_CITY, 'message' => '非精选城市');
     }
     // 获取房源基本信息
     $propInfo = Model_House_HzProp::get_prop_info_by_prop_id($houseId);
     $block_id = $propInfo['contentBasic']['blockid'];
     // 获取点击单价
     try {
         $clickPriceInfo = Bll_Service_Choice::hzClickPrice(array('cityId' => $cityId, 'price' => (int) $propInfo['contentBasic']['pricenum'], 'blockId' => $block_id, 'brokerId' => $brokerId));
         if ($clickPriceInfo['status'] == 'error') {
             return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => '', 'message' => '系统繁忙(code:-33)');
         }
     } catch (Exception $e) {
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => '', 'message' => '系统繁忙(code:-33)');
     }
     $params = array();
     $params['price'] = $clickPriceInfo['realTradeAmount'] / 100;
     // 点击单价单位转换:分 -> 元;
     $params['show'] = 0;
     $params['budget'] = $budget;
     $params['ip'] = $this->_request->get_client_ip();
     // 判断是否是重新推广
     $bllChoice = new Bll_Zufang_Choice();
     $planInfo = $bllChoice->get_plan_by_proid($houseId);
     //planning表中查找精选计划
     if (!empty($planInfo)) {
         $planId = $planInfo->plan_id;
         $basicPlanInfo = $bllChoice->get_plan($planId);
         if (!empty($basicPlanInfo)) {
             if ($basicPlanInfo[0]->status == 1 || $basicPlanInfo[0]->status == 13) {
                 return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => '', 'message' => '该房源已做精选推广!');
             }
             if ($basicPlanInfo[0]->status != Const_HzPlan::DELETE) {
                 $params['plan_id'] = $planInfo->plan_id;
             }
         }
     }
     // 开始精选推广
     $result = Bll_Plan_Bid_Choice::hz_setting_post($brokerId, $cityId, $houseId, $params);
     if ($result['err_no'] != Bll_Plan_Bid_Choice::BID_WAIT_SUCCESS) {
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => '', 'message' => $result['err_msg']);
     }
     if ($result['rank'] > 10) {
         $status = 2;
         $msg = "排在第{$result['rank']}位";
     } else {
         $status = 1;
         $msg = "精选推广成功";
     }
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('status' => $status, 'statusMsg' => $msg));
 }