Пример #1
0
 public function handle_request_internal()
 {
     $brokerId = $this->_params['brokerId'];
     $propId = $this->_params['propId'];
     $budget = $this->_params['budget'];
     $offer = $this->_params['offer'];
     //根据安居客经纪人ID获取好租经纪人ID
     $brokerId_hz = Bll_HzBroker::get_brokerid_by_ajk_brokerid($this->_params['brokerId']);
     if ($brokerId_hz) {
         $broker_info = Dao_Broker_HzPlan::get_hzbroker_info($brokerId_hz);
         if (!Bll_City::isBidCity($broker_info['cityid'])) {
             $error_code = Const_HzErrorInfo::NOBIDCITY;
             return array('status' => 'error', 'errcode' => $error_code, 'message' => Bll_HzFixPlan::get_message_from_code($error_code));
         }
     }
     $plan_id = Bll_HzBidPlan::get_planid_by_propid($propId);
     //@todo 不明白为什么一定要用propid而不用计划id
     $ret_offer = Bll_HzBidPlan::change_bid_offer($plan_id, $offer);
     //修改出价
     $ret_budget = Bll_HzBidPlan::change_bid_budget($plan_id, $budget);
     //修改预算 ----$new_amount 为需要增加的预算
     $r = array();
     if ($ret_offer['status'] && $ret_budget['status']) {
         $r = array('status' => 'ok', 'data' => array());
     } else {
         if (!$ret_offer['status']) {
             $r = array('status' => 'error', 'errcode' => $ret_offer['msg'], 'message' => Bll_HzFixPlan::get_message_from_code($ret_offer['msg']));
         }
         if (!$ret_budget['status']) {
             $r = array('status' => 'error', 'errcode' => $ret_budget['msg'], 'message' => Bll_HzFixPlan::get_message_from_code($ret_budget['msg']));
         }
     }
     return $r;
 }
Пример #2
0
 public function handle_request_internal()
 {
     $brokerId = $this->_params['brokerId'];
     // 判断经纪人是否存在
     $broker = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId);
     $hzBrokerId = Model_Broker_MainBusiness::getHzBrokerIdByAjkBrokerId($brokerId);
     if (!$hzBrokerId || !$broker) {
         throw new Exception_Broker_NotFound('BrokerId: ' . $brokerId);
     }
     // 判断城市是否开通竞价业务
     $cityId = $broker['cityId'];
     if (!Bll_City::isBidCity($cityId)) {
         return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('todayClicks' => 0, 'todayConsume' => 0, 'todayConsumeUnit' => '元', 'totalProps' => 0));
     }
     // 获取今日房源点击和消费记录
     $clicksInfo = Model_Stats_PropClick::getClickInfoByBrokerId($hzBrokerId, $cityId);
     // 统计今日竞价点击和消费
     $todayClicks = 0;
     $todayConsume = 0;
     foreach ($clicksInfo as $objClick) {
         $todayClicks += $objClick->bid_cnum;
         $todayConsume += $objClick->bid_cost;
     }
     // 获取竞价房源数
     $bidPropNum = Bll_HzBidPlan::get_broker_bidprop_count($hzBrokerId);
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('todayClicks' => $todayClicks, 'todayConsume' => Util_Formatter::formatTodayConsume($todayConsume / 100), 'todayConsumeUnit' => '元', 'totalProps' => $bidPropNum));
 }
Пример #3
0
 public function handle_request_internal()
 {
     //组织POST参数
     $params = array();
     if (!isset($this->_params['brokerId'])) {
         return Util_MobileAPI::error(Const_APIStatus::E_BROKER_PARAM_MISS);
     } else {
         $broker_id = $this->_params["brokerId"];
     }
     if (!isset($this->_params["cityId"])) {
         return Util_MobileAPI::error(Const_APIStatus::E_PARAM_CITYID_MISS);
     }
     if (!isset($this->_params["propId"])) {
         return Util_MobileAPI::error(Const_APIStatus::E_PROP_ID_MISS);
     }
     if (!isset($this->_params["offer"])) {
         return Util_MobileAPI::error(Const_APIStatus::E_PROP_BID_PRICE_MISS);
     }
     if (!Bll_City::isBidCity($this->_params["cityId"])) {
         $error_code = Const_HzErrorInfo::NOBIDCITY;
         return array('status' => 'error', 'errcode' => $error_code, 'message' => Bll_HzFixPlan::get_message_from_code($error_code));
     }
     $search = new Util_SearchUtil();
     $prop = Bll_HzProp::get_prop($this->_params["propId"]);
     $blockid = $prop['blockid'];
     $price = $prop['pricenum'];
     $price_block = Bll_HzBidPlan::get_price_block($this->_params["cityId"], $price);
     $ajkid = Bll_HzProp::get_subregion_id($prop['commId'], $this->_params["propId"]);
     $rank = $search->getHpRankByProp($this->_params["cityId"], $ajkid, $this->_params["propId"], $price_block['LOWER'], $price_block['UPPER'], $this->_params['offer']);
     $return = array();
     $return["status"] = "ok";
     $return["data"] = $rank;
     return $return;
 }
Пример #4
0
 public function handle_request_internal()
 {
     $propId = $this->_params['propId'];
     $minoffer = Bll_HzBidPlan::get_bid_minoffer($propId);
     $ret = array('status' => 'ok', 'data' => $minoffer);
     return $ret;
 }
 public function dealTask($task)
 {
     $currentUsedNum = $task['usedNum'];
     $trueUsedNum = Bll_HzBidPlan::countBucketChoicePlan($task['blockId'], $task['priceId']);
     printf('正在处理 队列id %s, blockId %s, priceId %s 结果是: userNum: %s, 实际: %s, 状态:%s' . PHP_EOL, $task['id'], $task['blockId'], $task['priceId'], $currentUsedNum, $trueUsedNum, $currentUsedNum == $trueUsedNum ? 'success' : 'error');
     if ($currentUsedNum == $trueUsedNum) {
         return true;
     }
     $result = Model_Choice_HzBidBucket::updateBucket(array('id' => $task['id']), array('usedNum' => $trueUsedNum));
     printf('更新usedNum结果: %s' . PHP_EOL, $result ? '更新成功' : '更新失败');
     return true;
 }
Пример #6
0
 public function handle_request_internal()
 {
     //根据安居客经纪人ID获取好租经纪人ID
     $brokerId = $this->_params['brokerId'];
     $brokerId_hz = Bll_HzBroker::get_brokerid_by_ajk_brokerid($this->_params['brokerId']);
     $city_id = $this->_params['cityId'];
     //get bid flg for city
     $choiceCityFlag = Bll_City::isChoiceCity($city_id, Const_Site::HAOZU);
     if ($choiceCityFlag) {
         return array('status' => 'ok', 'data' => array('propertyList' => array(), 'codeNum' => Const_HzErrorInfo::NOBIDCITY));
     }
     $result = Bll_HzBidPlan::get_broker_bidprop($brokerId_hz, $city_id);
     if (!empty($result)) {
         $props = array();
         foreach ($result as $key => $prop) {
             $prop_basic['id'] = $prop['proid'];
             $prop_basic['title'] = $prop['prop']['content_basic']['title'];
             $prop_basic['commId'] = $prop['prop']['content_basic']['commid'];
             $prop_basic['commName'] = $prop['prop']['content_basic']['commname'];
             $prop_basic['roomNum'] = $prop['prop']['content_basic']['roomnum'];
             $prop_basic['hallNum'] = $prop['prop']['content_basic']['hallnum'];
             $prop_basic['toiletNum'] = $prop['prop']['content_basic']['toilnetnum'];
             $prop_basic['area'] = round($prop['prop']['content_basic']['areanum']);
             $prop_basic['price'] = round($prop['prop']['content_basic']['pricenum']);
             $prop_basic['priceUnit'] = "元";
             $prop_basic['bidStatus'] = $prop['plan']['status'];
             $prop_basic['index'] = $prop['rank'];
             $prop_basic['clickNum'] = $prop['clicks'];
             $prop_basic['offer'] = $prop['offer'];
             $prop_basic['budget'] = $prop['reconsume'];
             $prop_basic['yusuan'] = $prop['consume'];
             if ($prop['plan']['status'] != 1) {
                 $prop_basic['yusuan'] = 20;
                 $prop_basic['bidStatus'] = 3;
                 //@todo 此处是个坑,后续要改
             }
             //增加委托房源标签
             $isEntrust = Bll_Zufang_Choice::isCommissionHouse($prop['proid'], $brokerId, Model_House_Commission::TYPE_RENT);
             if ($isEntrust) {
                 $prop_basic['isEntrust'] = 1;
             } else {
                 $prop_basic['isEntrust'] = 0;
             }
             $prop_basic['planId'] = $key;
             $props['propertyList'][] = $prop_basic;
         }
     } else {
         $props['propertyList'] = array();
     }
     $ret = array('status' => 'ok', 'data' => $props);
     return $ret;
 }
Пример #7
0
 public function handle_request_internal()
 {
     //根据安居客经纪人ID获取好租经纪人ID
     $brokerId_hz = Bll_HzBroker::get_brokerid_by_ajk_brokerid($this->_params['brokerId']);
     if ($brokerId_hz) {
         $broker_info = Dao_Broker_HzPlan::get_hzbroker_info($brokerId_hz);
         if (!Bll_City::isBidCity($broker_info['cityid'])) {
             $error_code = Const_HzErrorInfo::NOBIDCITY;
             return array('status' => 'error', 'errcode' => $error_code, 'message' => Bll_HzFixPlan::get_message_from_code($error_code));
         }
     }
     $ret = Bll_HzBidPlan::prop_out_bid($brokerId_hz, $this->_params['propId']);
     $r = array();
     if ($ret['status']) {
         $r = array('status' => 'ok', 'data' => array());
     } else {
         return Util_MobileAPI::error(Const_APIStatus::E_PLAN_PARAM_ERR);
     }
     return $r;
 }
Пример #8
0
 public function handle_request_internal()
 {
     //根据安居客经纪人ID获取好租经纪人ID
     $brokerId_hz = Bll_HzBroker::get_brokerid_by_ajk_brokerid($this->_params['brokerId']);
     if ($brokerId_hz) {
         $broker_info = Dao_Broker_HzPlan::get_hzbroker_info($brokerId_hz);
         if (!Bll_City::isBidCity($broker_info['cityid'])) {
             $error_code = Const_HzErrorInfo::NOBIDCITY;
             return array('status' => 'error', 'errcode' => $error_code, 'message' => Bll_HzFixPlan::get_message_from_code($error_code));
         }
     }
     $propId = $this->_params['propId'];
     $planId = $this->_params['planId'];
     $ret = Bll_HzBidPlan::delete_bid($brokerId_hz, $planId, $propId);
     //竞价解冻开发中
     if ($ret['status']) {
         $r = array('status' => 'ok', 'data' => array());
     } else {
         $r = array('status' => 'error', 'errcode' => $ret['msg'], 'message' => Bll_HzFixPlan::get_message_from_code($ret['msg']));
     }
     return $r;
 }
Пример #9
0
 public function handle_request_internal()
 {
     //根据安居客经纪人ID获取好租经纪人ID
     $brokerId_hz = Bll_HzBroker::get_brokerid_by_ajk_brokerid($this->_params['brokerId']);
     $proid = $this->_params['propId'];
     $cityId = $this->_params['cityId'];
     if (!Bll_City::isBidCity($cityId)) {
         $error_code = Const_HzErrorInfo::NOBIDCITY;
         return array('status' => 'error', 'errcode' => $error_code, 'message' => Bll_HzFixPlan::get_message_from_code($error_code));
     }
     $offer = $this->_params['offer'];
     //offer竞价出价
     $budget = $this->_params['budget'];
     //amount竞价预算(冻结金额)
     $ret = Bll_HzBidPlan::prop_into_bid($brokerId_hz, $cityId, $proid, $offer, $budget, $this->_params['brokerId']);
     $r = array();
     if ($ret['status']) {
         $r = array('status' => 'ok', 'data' => array());
     } else {
         $r = array('status' => 'error', 'errcode' => $ret['msg'], 'message' => Bll_HzFixPlan::get_message_from_code($ret['msg']));
     }
     return $r;
 }
Пример #10
0
 /**
  * 房源添加竞价/更新竞价 判断
  */
 public static function check_bid($proid, $broker_id, $offer, $amount, $ajkBrokerId = 0)
 {
     $proinfo = Dao_Broker_HzProp::get_prop($proid);
     $basic_info = $proinfo[$proid]['content_basic'];
     if (empty($basic_info)) {
         $flag_array['msg'] = Const_HzErrorInfo::PROPERROR;
         return $flag_array;
     }
     if ($basic_info['userid'] != $broker_id) {
         $flag_array['msg'] = Const_HzErrorInfo::PROPFAIL;
         return $flag_array;
     }
     if (!$basic_info['quality']) {
         $flag_array['msg'] = Const_HzErrorInfo::PROPPIC;
         return $flag_array;
     }
     $bid_min_offer = self::get_bid_minoffer($proid);
     if ((int) ($offer * 100) < (int) ($bid_min_offer * 100)) {
         $flag_array['msg'] = Const_HzErrorInfo::BIDOFFERFAIL;
         return $flag_array;
     }
     if ((int) ($offer * 100) > (int) ($amount * 100)) {
         $flag_array['msg'] = Const_HzErrorInfo::BIDOFFERTOP;
         return $flag_array;
     }
     if ($amount < 20) {
         $flag_array['msg'] = Const_HzErrorInfo::BIDAMOUNT;
         return $flag_array;
     }
     $bid_planning = Dao_Broker_HzPlan::get_prop_planning($proid, Const_HzPlan::BID_TYPE, '1');
     if (!empty($bid_planning)) {
         $flag_array['msg'] = Const_HzErrorInfo::PROPBID;
         return $flag_array;
     }
     if ($ajkBrokerId) {
         //判断房源是否加入定价计划或者套餐
         $isComboBroker = Bll_Broker_HzBroker::isComboBroker($ajkBrokerId);
         if ($isComboBroker) {
             //判断房源是否加入套餐
             $comboInfo = Bll_Combo_HouseRelation::getHouseRelation($ajkBrokerId, $basic_info['cityid'], $proid, Bll_Combo_HouseRelation::SITE_TYPE_HZ);
             if (!(!empty($comboInfo) && $comboInfo[0]['state'] > 100 & $comboInfo[0]['state'] < 200)) {
                 $flag_array['msg'] = Const_HzErrorInfo::NOCOMBOPROP;
                 return $flag_array;
             }
         } else {
             $fix_planning = Dao_Broker_HzPlan::get_prop_planning($proid);
             if (empty($fix_planning)) {
                 $flag_array['msg'] = Const_HzErrorInfo::PROPNOTFIX;
                 return $flag_array;
             }
         }
     } else {
         $fix_planning = Dao_Broker_HzPlan::get_prop_planning($proid);
         if (empty($fix_planning)) {
             $flag_array['msg'] = Const_HzErrorInfo::PROPNOTFIX;
             return $flag_array;
         }
     }
     $bidprops = Bll_HzBidPlan::get_broker_bidprop($broker_id, $basic_info['cityid']);
     //@todo 此处是个坑,值得优化哦
     //$plans = Dao_Broker_HzPlan::get_broker_plan($broker_id, '1,3,7,8', Const_HzPlan::BID_TYPE);
     if (count($bidprops) >= 10) {
         $flag_array['msg'] = Const_HzErrorInfo::PROPBIDTEN;
         return $flag_array;
     }
     $broker_info = Dao_Broker_HzPlan::get_hzbroker_info($broker_id);
     if ($broker_info['profile_verify'] != 2) {
         $flag_array['msg'] = Const_HzErrorInfo::BROKERCHECK;
         return $flag_array;
     }
     $balance = Bll_PayAccount::get_broker_balance($broker_id);
     if ((int) ($amount * 100) > (int) ($balance * 100)) {
         $flag_array['msg'] = Const_HzErrorInfo::BIDAMOUNTTOP;
         return $flag_array;
     }
     $flag_array['status'] = 1;
     return $flag_array;
 }
Пример #11
0
 /**
  * 竞价临时处理方法。 后期挂job处理
  */
 private function tempDoBid()
 {
     // 竞价暂时这面做掉
     $outBidResult = Bll_HzBidPlan::bidPropOutBid($this->params['broker_id'], $this->params['pro_id']);
     $this->allReturn[] = $outBidResult['msg'];
 }
Пример #12
0
 /**
  * 将单个房源从定价组中移除
  */
 public static function prop_out_fix($broker_id, $proid, $plan_id)
 {
     $flag_array = array('status' => 0, 'msg' => '');
     $proinfo = Dao_Broker_HzProp::get_prop($proid);
     if (empty($proinfo[$proid])) {
         $flag_array['msg'] = Const_HzErrorInfo::PROPNULL;
         return $flag_array;
     }
     $plan_info = Dao_Broker_HzPlan::get_plan($plan_id);
     if (empty($plan_info)) {
         $flag_array['msg'] = Const_HzErrorInfo::NULLPLAN;
         return $flag_array;
     }
     if ($plan_info['user_id'] != $broker_id) {
         $flag_array['msg'] = Const_HzErrorInfo::PLANINFOERROR;
         return $flag_array;
     }
     if ($proinfo[$proid]['content_basic']['userid'] != $plan_info['user_id']) {
         $flag_array['msg'] = Const_HzErrorInfo::PROPUSERNULL;
         return $flag_array;
     }
     $planning = Dao_Broker_HzPlan::get_check_planning($proid, $plan_id);
     if (empty($planning)) {
         $flag_array['msg'] = Const_HzErrorInfo::PROPFIXNULL;
         return $flag_array;
     }
     //写入定价上下架队列表
     $ProPlanChangeApiBll = Bll_ProPlanChangeApiBll::get_instance();
     $ajkBrokerId = Model_Broker_HzMapping::get_ajk_broker_id($broker_id);
     $ProPlanChangeApiBll->insertProPlanChange(array('broker_id' => $ajkBrokerId, 'pro_id' => $proid, 'plan_id' => $plan_id, 'type' => 'pro_del_from_plan', 'from' => 'hz_' . __CLASS__ . '_' . __FUNCTION__, 'remark' => json_encode(array('fix' => array('plan_status' => 1))), 'site_type' => 2), $ajkBrokerId);
     $bid = Dao_Broker_HzPlan::get_prop_planning($proid, Const_HzPlan::BID_TYPE, '1');
     if (!empty($bid)) {
         //停止竞价
         $deleteBidResult = Bll_HzBidPlan::delete_bid($broker_id, $bid[0]['plan_id'], $proid);
     }
     $log_option = Const_HzLog::PAUSEPLAN;
     $new_is_valid = Const_HzPlan::MENUPAUSE;
     $basic_info = $proinfo[$proid]['content_basic'];
     //更新房源计划信息
     if (Dao_Broker_HzProp::change_prop_status($proid, Const_HzStatus::OUTLINE)) {
         //更新房源状态
         if (Dao_Broker_HzPlan::update_planning($planning[0]['id'], $new_is_valid)) {
             //更新关联关系
             Dao_Broker_HzPlan::add_prop_log($proid, $log_option, $basic_info['userid'], $plan_id, $basic_info['status'], Const_HzStatus::OUTLINE);
             //记房源日志
             if ($basic_info['status'] == Const_HzStatus::ONLINE) {
                 //插入solr队列,房源下线
                 Dao_Broker_HzProp::into_prop_lucene($proid, $basic_info['cityid'], 2);
                 //写日志
                 Dao_Broker_HzProp::ezft_assistant_log($planning[0]['proid'], $basic_info['userid'], Const_HzPlan::SPREAD_TYPE, $basic_info['spread_type']);
                 Dao_Broker_HzProp::add_updown_log($planning[0]['proid'], $plan_id, Const_HzStatus::GOOFFLINE, $log_option);
             }
             $flag_array['status'] = 1;
             return $flag_array;
         }
     }
     $flag_array['msg'] = Const_HzErrorInfo::DATAFAIL;
     return $flag_array;
 }
Пример #13
0
 /**
  * 精选房源设置
  *
  * @param $ajk_broker_id
  * @param $city_id
  * @param $prop_id
  * @param array $params
  *
  * @return array
  */
 public static function hz_setting_post($ajk_broker_id, $city_id, $prop_id, $params = array())
 {
     //获取精选推广预算
     $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])) {
         $min_budget = $choiceSet[$brokerCompanyId]['hz']['HZ_CHOICE_MIN_BUDGET'];
         $max_budget = $choiceSet[$brokerCompanyId]['hz']['HZ_CHOICE_MAX_BUDGET'];
     } else {
         $min_budget = $choiceSet['default']['hz']['HZ_CHOICE_MIN_BUDGET'];
         $max_budget = $choiceSet['default']['hz']['HZ_CHOICE_MAX_BUDGET'];
     }
     if ($params['budget'] < $min_budget || $params['budget'] > $max_budget) {
         return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '推广预算,最低' . $min_budget . '安币,最高' . $max_budget . '安币');
     }
     $result = array();
     $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' => '您不是好租经纪人');
     }
     /** 判断房源是否可以精选 */
     $checkProp = Bll_HzBidPlan::checkPropCanChoice($ajk_broker_id, $city_id, $prop_id);
     if ($checkProp['err_no'] != 0) {
         return $checkProp;
     }
     /** 防并发 */
     if (false === self::rejectSameRequest(Bll_Plan_Bid_Choice::SITE_HAOZU, $ajk_broker_id, $prop_id)) {
         return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '系统繁忙(code:-906)');
     }
     /** 获取房源基本信息 */
     $propInfo = Model_House_HzProp::get_prop_info_by_prop_id($prop_id);
     /** 获取点击单价 */
     try {
         /**
          * @var Bll_Service_Client_HttpResponse $clickPrice
          */
         for ($i = 0; $i < 3; $i++) {
             $clickPrice = Bll_Service_Choice::hzClickPrice(array('brokerId' => $ajk_broker_id, 'cityId' => $city_id, 'price' => (int) $propInfo['contentBasic']['pricenum'], 'blockId' => $propInfo['contentBasic']['blockid']));
             if ($clickPrice->isSucceeded()) {
                 break;
             }
         }
         if (!$clickPrice->isSucceeded() || $clickPrice['status'] == 'error') {
             return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '系统繁忙(code:-' . __LINE__ . ')');
         }
         if ($params['budget'] * 100 < $clickPrice['realTradeAmount']) {
             return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '推广预算不能小于点击单价');
         }
         /** 点击单价不能小于当前系统内的单价 防止恶意操作 */
         if ($params['price'] < $clickPrice['realTradeAmount'] / 100) {
             return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '点击单价错误');
         }
     } catch (Exception $e) {
         return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '系统繁忙(code:-' . __LINE__ . ')');
     }
     $block_id = $propInfo['contentBasic']['blockid'];
     $priceIntervalInfo = Model_House_HzPriceChoice::get_price($city_id, $propInfo['contentBasic']['pricenum']);
     if (empty($priceIntervalInfo)) {
         $logContent = sprintf('%s ajkBrokerId=%d hzBrokerId=%d cityId=%d propId=%d blockId=%d priceNum=%s %s', date('Y-m-d H:i:s'), $ajk_broker_id, $hz_broker_id, $city_id, $prop_id, $block_id, $propInfo['contentBasic']['pricenum'], '好租城市的价格段获取失败');
         APF::get_instance()->get_nlogger()->log('好租城市的价格段', $logContent);
         return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '系统烦忙(code:-' . __LINE__ . ')');
     }
     /** 获取坑位信息 提前判断坑位状态 没有的话会自动初始化一个 */
     $bucketInfo = Bll_Choice_HzBidBucket::getBucketInfo($block_id, $priceIntervalInfo['id']);
     if (empty($bucketInfo)) {
         return array('err_no' => self::BID_WAIT_FAIL, 'err_msg' => '精选房源推广失败');
     }
     /** 精选房源展示推广 */
     if (isset($params['show']) && $params['show'] == 1) {
         $result = array('err_no' => self::BID_SHOW_SUCCESS, 'err_msg' => '精选房源推广成功');
         if ($bucketInfo['usedNum'] >= $bucketInfo['maxOnlineNum']) {
             return array('err_no' => self::BID_SHOW_FAIL, 'err_msg' => '精选房源推广失败');
         }
         /** 展示位 坑位自增 */
         $lockBucket = Model_Choice_HzBidBucket::increment_used_num_online($block_id, $priceIntervalInfo['id']);
         if (!$lockBucket) {
             return array('err_no' => self::BID_SHOW_FAIL, 'err_msg' => '精选房源推广失败');
         }
     } else {
         $result = array('err_no' => self::BID_WAIT_SUCCESS, 'err_msg' => '精选房源推广成功');
         if ($bucketInfo['usedNum'] >= $bucketInfo['totalNum']) {
             return array('err_no' => self::BID_WAIT_FAIL, 'err_msg' => '推广位已满!');
         }
         /** 排队位置 坑位自增 */
         $lockBucket = Model_Choice_HzBidBucket::increment_used_num($block_id, $priceIntervalInfo['id']);
         if (!$lockBucket) {
             return array('err_no' => self::BID_WAIT_FAIL, 'err_msg' => '精选房源推广失败');
         }
     }
     /** 往冻结队列里添加记录,获取request id*/
     $bidFreezeOrder = new Bll_Plan_BidFreezeOrderNum(date('Y'));
     $ajk_user_id = Bll_Broker_MainBusiness::getDataByEsfId($ajk_broker_id)->memberId;
     $requestId = $bidFreezeOrder->getRequestId(Bll_Plan_BidFreezeOrderNum::HZ, $ajk_user_id, date('Y'), 0, $prop_id);
     /** 冻结金额 */
     $freezeResult = self::hz_bid_freeze($ajk_broker_id, $params['budget'] * 100, $requestId, sprintf('好租精选房源冻结,propId: %d', $prop_id));
     if (!$freezeResult->isSucceeded() || $freezeResult['status'] == 'error') {
         Model_Choice_HzBidBucket::decrement_used_num($block_id, $priceIntervalInfo['id']);
         return array('err_no' => self::BID_FAIL_QUALITY_OR_NEW, 'err_msg' => isset($freezeResult['info']) ? $freezeResult['info'] : '冻结金额失败');
     }
     $sn = $freezeResult['data']['sn'];
     if (!isset($params['plan_id']) || empty($params['plan_id'])) {
         $createdRemark = sprintf('经纪人开始精选房源推广 SN:%s', $sn);
         $resultPlan = Bll_Plan_Bid_HzBid::add_plan($hz_broker_id, $prop_id, $params['price'], $params['budget'], $block_id, $city_id, $sn, $ajk_broker_id);
         /** 添加计划失败 */
         if ($resultPlan['error_code'] != 0) {
             Model_Choice_HzBidBucket::decrement_used_num($block_id, $priceIntervalInfo['id']);
             return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => $resultPlan['error_message']);
         }
         $planId = $resultPlan['planId'];
     } else {
         $createdRemark = sprintf('经纪人重新推广精选房源 SN:%s', $sn);
         /** 更新精选房源计划预算 */
         $planId = $params['plan_id'];
         $resultPlan = Bll_Plan_Bid_HzBid::update_bid($hz_broker_id, $planId, $prop_id, $params['price'], $params['budget'], $city_id, $sn, $ajk_broker_id);
         if ($resultPlan['error_code'] != 0) {
             Model_Choice_HzBidBucket::decrement_used_num($block_id, $priceIntervalInfo['id']);
             return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => $resultPlan['error_message']);
         }
         $planId = $resultPlan['planId'];
     }
     $result['rank'] = Bll_Plan_Bid_HzBid::getChoiceWaitPosition($planId, $city_id, $block_id, $priceIntervalInfo['id']);
     /** 精选房源成功 */
     $actionQueueData = array('siteType' => Model_Choice_ActionQueue::ENUM_HAOZU, 'brokerId' => $ajk_broker_id, 'planId' => $planId, 'proId' => $prop_id, 'actionId' => Model_Choice_ActionQueue::ENUM_BEGIN_BY_HAND, 'createTime' => time(), 'createRemark' => $createdRemark, 'operationId' => $ajk_broker_id, 'ip' => $params['ip']);
     Model_Choice_ActionQueue::addBidQueen($actionQueueData);
     $bidFreezeOrder->updateRequestComplete($requestId, $sn, $planId);
     return $result;
 }
Пример #14
0
 public function handle_request_internal()
 {
     /*
     @params planId :计划id
     @params resType :默认为0,0表示不取计划房源信息,1为取房源信息
     @params from :来源
     @success return 该计划id的信息
     */
     if (!isset($this->_params['brokerId'])) {
         return Util_MobileAPI::error(Const_APIStatus::E_PLAN_PARAM_BROKERID_MISS);
     }
     $brokerId = $this->_params['brokerId'];
     //根据安居客经纪人ID获取好租经纪人ID
     $brokerId_hz = Bll_HzBroker::get_brokerid_by_ajk_brokerid($brokerId);
     if ($brokerId_hz) {
         $broker_info = Dao_Broker_HzPlan::get_hzbroker_info($brokerId_hz);
         if (!Bll_City::isBidCity($broker_info['cityid'])) {
             return array('status' => 'ok', 'data' => array('propertyList' => array()));
         }
     }
     if (Bll_Broker_HzBroker::isComboBroker($brokerId)) {
         //获取套餐推广房源列表
         $comboList = Bll_Combo_HouseRelation::getHouseRelations($brokerId, Bll_Combo_HouseRelation::SITE_TYPE_HZ, 1);
         if (!empty($comboList)) {
             foreach ($comboList as $combo) {
                 $comboIds[$combo['houseId']] = 1;
             }
             //获取竞价房源 去除竞价房源
             $validBidPlans = Model_Plan_HzPlanBasic::getBidPlansByBrokerId($brokerId_hz);
             $planIds = array();
             if (!empty($validBidPlans)) {
                 foreach ($validBidPlans as $plan) {
                     if ($plan['flag'] == 1 && $plan['status'] != Const_HzPlan::DELETE) {
                         $planIds[] = $plan['id'];
                     }
                 }
                 if (!empty($planIds)) {
                     $bidPlannings = Model_Plan_HzPlanning::getPlanningByPlanIds($planIds);
                 }
                 if (!empty($bidPlannings)) {
                     foreach ($bidPlannings as $bid) {
                         unset($comboIds[$bid['proid']]);
                     }
                 }
             }
             //$propertyList = Model_House_HzProp::getPropsByPropIds(array_keys($comboIds));
             $propertyList = Dao_Broker_HzProp::get_prop(array_keys($comboIds));
             if (!empty($propertyList)) {
                 foreach ($propertyList as $key => $list) {
                     if ($list['content_basic']['quality'] != 1) {
                         unset($propertyList[$key]);
                     }
                 }
             }
             $result = $propertyList;
         } else {
             $result = array();
         }
         //去除竞价房源和非多图房源
     } else {
         $result = Bll_HzBidPlan::get_canbid_props($brokerId_hz);
     }
     $return = array();
     $return["status"] = "ok";
     $return["data"]['propertyList'] = array();
     if (!empty($result)) {
         $proprow = array();
         foreach ($result as $propertyList) {
             $proprow["id"] = $propertyList['proid'];
             $proprow["title"] = $propertyList['content_basic']['title'];
             $proprow["commId"] = $propertyList['content_basic']['commid'];
             $proprow["commName"] = $propertyList['content_basic']['commname'];
             $proprow["roomNum"] = $propertyList['content_basic']['roomnum'];
             $proprow["hallNum"] = $propertyList['content_basic']['hallnum'];
             $proprow["toiletNum"] = $propertyList['content_basic']['toilnetnum'];
             $proprow["area"] = round($propertyList['content_basic']['areanum']);
             $proprow["price"] = round($propertyList['content_basic']['pricenum']);
             $proprow["isMoreImg"] = $propertyList['content_basic']['quality'] ? 1 : 0;
             $proprow["priceUnit"] = "元";
             $return["data"]['propertyList'][] = $proprow;
             unset($proprow);
         }
         unset($result);
     }
     return $return;
 }
Пример #15
0
 /**
  * 停止竞价
  */
 public function do_stop()
 {
     return Bll_HzBidPlan::bidPropOutBid($this->params['hzBrokerId'], $this->params['proId'], false);
 }
Пример #16
0
 public function handle_request_internal()
 {
     $brokerId = $this->_params['brokerId'];
     // 判断经纪人是否存在
     $broker = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId);
     $hzBrokerId = Model_Broker_MainBusiness::getHzBrokerIdByAjkBrokerId($brokerId);
     if (!$hzBrokerId || !$broker) {
         throw new Exception_Broker_NotFound('BrokerId: ' . $brokerId);
     }
     // 判断城市是否开通竞价业务
     $cityId = $broker['cityId'];
     if (!Bll_City::isBidCity($cityId)) {
         throw new Exception_City_NotBidCity('CityId: ' . $cityId);
     }
     // 获取竞价房源
     $finalProps = array();
     $bidProps = Bll_HzBidPlan::get_broker_bidprop($hzBrokerId, $cityId);
     foreach ($bidProps as $bidProp) {
         $row = array();
         $row['propId'] = $bidProp['proid'];
         $row['title'] = $bidProp['prop']['content_basic']['title'];
         $row['imgUrl'] = '';
         $row['commId'] = $bidProp['prop']['content_basic']['commid'];
         $row['commName'] = $bidProp['prop']['content_basic']['commname'];
         $row['roomNum'] = $bidProp['prop']['content_basic']['roomnum'];
         $row['hallNum'] = $bidProp['prop']['content_basic']['hallnum'];
         $row['toiletNum'] = $bidProp['prop']['content_basic']['toilnetnum'];
         $row['area'] = round($bidProp['prop']['content_basic']['areanum']);
         $row['price'] = round($bidProp['prop']['content_basic']['pricenum']);
         $row['priceUnit'] = "元/月";
         $row['totalClicks'] = 0;
         $row['isBid'] = 1;
         $row['isChoice'] = 0;
         $row['isVisible'] = (int) ($bidProp['content_basic']['status'] != 6);
         $row['isMoreImg'] = (int) $bidProp['content_basic']['quality'];
         $row['isPhonePub'] = (int) (isset($bidProp['content_basic']['from']) && $bidProp['content_basic']['from'] == 'mobile-ajk-broker');
         // TODO 批量判定 增加委托房源标签
         $isEntrust = Bll_Zufang_Choice::isCommissionHouse($bidProp['proid'], $brokerId, Model_House_Commission::TYPE_RENT);
         if ($isEntrust) {
             $row['isEntrust'] = 1;
         } else {
             $row['isEntrust'] = 0;
         }
         // 确认房源分组
         // TODO 基于Rank获取分组可能对页面速度有一定影响
         $row['rank'] = $bidProp['rank'];
         if ($row['rank'] === '已暂停') {
             $row['group'] = 'offline';
         } elseif ($row['rank'] === '排队中') {
             $row['group'] = 'queued';
         } else {
             $row['group'] = 'online';
         }
         $finalProps[$row['propId']] = $row;
     }
     if ($finalProps) {
         $propIds = array_keys($finalProps);
         // 批量获取房源的默认图片
         $defaultImages = Model_Image_HzImage::getDefaultImagesByHouseIds($propIds);
         foreach ($defaultImages as $defaultImage) {
             $finalProps[$defaultImage['proid']]['imgUrl'] = $defaultImage->imageUrl();
         }
         // 批量获取房源的竞价总点击
         $bidClicks = Model_Stats_PropClick::getPropAllClicks($propIds, $brokerId, $cityId);
         $bidClickSums = Model_Stats_PropClick::calculateClickSumsGroupByPropId($bidClicks, 'bid');
         foreach ($bidClickSums as $propId => $bidClickSum) {
             $finalProps[$propId]['totalClicks'] = $bidClickSum;
         }
     }
     // 排序 • 按ID倒序
     ksort($finalProps);
     // 分组
     $props = array('onlinePropertyList' => array(), 'queuedPropertyList' => array(), 'offlinePropertyList' => array());
     foreach ($finalProps as $finalProp) {
         switch ($finalProp['group']) {
             case 'online':
                 $props['onlinePropertyList'][] = $finalProp;
                 break;
             case 'queued':
                 $props['queuedPropertyList'][] = $finalProp;
                 break;
             case 'offline':
                 $props['offlinePropertyList'][] = $finalProp;
                 break;
         }
     }
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => $props);
 }
Пример #17
0
 /**
  * 更新坑位信息,重新计算
  *
  * @param int $blockId
  * @param int $priceId
  * @return bool
  */
 private static function updateBucket($blockId, $priceId)
 {
     $bucketCount = Bll_HzBidPlan::countBucketChoicePlan($blockId, $priceId);
     $bucketInfo = Bll_Choice_HzBidBucket::getBucketInfo($blockId, $priceId);
     if (empty($bucketInfo)) {
         $bucketInfo = Bll_Choice_HzBidBucket::init_bucket_info($blockId, $priceId);
     }
     if ($bucketInfo['usedNum'] == $bucketCount) {
         return true;
     }
     $condition = array('blockId' => $blockId, 'priceId' => $priceId);
     return 1 == Model_Choice_HzBidBucket::updateBucket($condition, array('usedNum' => min($bucketCount, $bucketInfo['totalNum'])));
 }
Пример #18
0
 /**
  * 计算竞价房源排名
  * @param $proId
  * @param $commId
  * @param $priceNum
  * @param $unitPrice
  * @param $cityId
  * @return int
  */
 public static function getBidRank($proId, $commId, $priceNum, $unitPrice, $cityId)
 {
     // 获取价格段
     $priceBlock = Bll_HzBidPlan::get_price_block($cityId, $priceNum);
     // 板块id
     $ajkid = Bll_HzProp::get_subregion_id($commId, $proId);
     $rank = Util_SearchUtil::getHpCurrentRank($cityId, $ajkid, $proId, $priceBlock['LOWER'], $priceBlock['UPPER'], $unitPrice);
     if ($rank > 5) {
         $rank = '排队中';
     }
     return $rank;
 }
Пример #19
0
 public function handle_request_internal()
 {
     $brokerId = $this->_params['brokerId'];
     $propId = $this->_params['propId'];
     // 判断经纪人是否存在
     $broker = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId);
     $hzBrokerId = Model_Broker_MainBusiness::getHzBrokerIdByAjkBrokerId($brokerId);
     if (!$hzBrokerId || !$broker) {
         throw new Exception_Broker_NotFound('BrokerId: ' . $brokerId);
     }
     // 判断城市是否开通竞价业务
     $cityId = $broker['cityId'];
     if (!Bll_City::isBidCity($cityId)) {
         throw new Exception_City_NotBidCity('CityId: ' . $cityId);
     }
     // 获取房源信息
     $prop = Model_House_HzProp::findByPropId($propId);
     /* @var Model_House_HzProp $prop */
     if (!$prop) {
         throw new Exception_Property_NotFound("Zufang propId: {$propId}");
     }
     // TODO 是否需要判断房源是否已删除
     // 判断房源是否属于经纪人
     if ($prop->getContentBasic('userid') != $hzBrokerId) {
         throw new Exception_Property_NotFound("Zufang propId: {$propId} not belog to broker: {$brokerId}");
     }
     // 准备默认返回数据(房源未竞价)
     $data = array('planId' => 0, 'status' => 0, 'rank' => -1, 'rankMsg' => '已暂停', 'todayClicks' => 0, 'totalClicks' => 0, 'clickPrice' => 0, 'clickPriceUnit' => '元', 'minClickPrice' => $prop->getBidMinClickPrice(), 'minClickPriceUnit' => '元', 'budget' => 0, 'budgetUnit' => '元', 'budgetRemain' => 0, 'budgetRemainUnit' => '元');
     // 获取竞价计划
     $bidPlan = $prop->getBidPlan();
     if (!$bidPlan) {
         // 判断房源是否多图房源
         if (!$prop->isMultiImages()) {
             throw new Exception_Property_NotMultiImages("Zufang propId: {$propId}");
         }
         // TODO 判断是否定价推广(也许可以不用,因为只有从定价推广房源列表点进去的房源详情页才会请求该接口)
     } else {
         // 竞价计划ID
         $data['planId'] = $bidPlan['id'];
         // 竞价计划状态
         switch ($bidPlan['status']) {
             case Const_HzPlan::SPREAD:
                 $data['status'] = 1;
                 // 推广中 or 排队中
                 break;
             case Const_HzPlan::MENUOVER:
                 $data['status'] = 2;
                 // 已暂停
                 break;
         }
         // 竞价预算
         $data['budget'] = round($bidPlan['amount'], 2);
         // 竞价预算余额
         $data['budgetRemain'] = round($bidPlan['amount'] - $bidPlan['total_consume'], 2);
         // 竞价排名
         if ($data['status'] == 1) {
             $data['rank'] = Bll_HzBidPlan::get_bid_rank($prop->getContentBasic(), $cityId);
             if ($data['rank'] <= 5) {
                 $data['rankMsg'] = '';
             } else {
                 $data['rankMsg'] = '排队中';
             }
         }
         // 竞价点击单价
         $bidRelation = $prop->getBidRelation();
         $data['clickPrice'] = round($bidRelation['unit_price'], 2);
         // 竞价点击底价
         $data['minClickPrice'] = round($prop->getBidMinClickPrice(), 2);
         // 今日竞价点击量
         $data['todayClicks'] = $prop->getTodayClickSums('bid');
         // 竞价点击总量
         $data['totalClicks'] = $prop->getTotalClickSums('bid');
     }
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => $data);
 }