コード例 #1
0
 public function run()
 {
     //获取精选符合的精选计划
     $planInfos = Model_Plan_Jp::getValidChoicePlanByCursor($this->cursor, $this->limit);
     //无需要处理的数据
     if (empty($planInfos)) {
         $this->setShStopFlag();
         $this->setCursor(0);
         $this->logQuit("无需要处理的数据.");
     }
     foreach ($planInfos as $plan) {
         $cityId = $plan->cityId;
         $houseType = $plan->houseType;
         /** 获取房源基本信息 */
         $propInfo = Bll_House_JpHouseInfo::getHouseInfoById($plan->houseId);
         /** 获取价格信息 **/
         $arrPrice = Bll_House_JpHouseInfo::getPrice($cityId, $propInfo['base']['houseType'], $propInfo['info']);
         //获取二手房经纪人id
         $mainBusiness = Model_Broker_MainBusiness::getMainBusinessByJpBrokerId($plan['memberId'], false);
         //获取点击单击
         $apiParams = array('brokerId' => $mainBusiness['ajkBrokerid'], 'cityId' => $cityId, 'price' => $arrPrice['price'] ?: 0, 'blockId' => $plan->blockId, 'newBlockId' => $plan->newBlockId, 'houseType' => $houseType);
         $clickPrice = Bll_Service_Choice::jpClickPrice($apiParams);
         if ($clickPrice['status'] == 'error') {
             $this->logQuit(sprintf('计划%d获取对应的点击单价失败', $plan->id));
         }
         $spreadPrice = $clickPrice['realTradeAmount'];
         //更新点击单价
         $oldSpreadPrice = $propInfo['info']->spreadPrice;
         $propInfo['info']->spreadPrice = $spreadPrice;
         $propInfo['info']->save();
         $this->addLogger(sprintf("计划%dspreadPrice修改,%d=>%d", $plan->id, $oldSpreadPrice, $spreadPrice));
         //更新游标
         $this->setCursor($plan->id);
     }
 }
コード例 #2
0
 public function openSaveBluewhaleHouse($houseId, $date, $spreadId, $spreadType)
 {
     $param = array();
     $HouseInfo = Bll_House_JpHouseInfo::getHouseInfoById($houseId);
     if ($HouseInfo['base']) {
         $param['house_type'] = $HouseInfo['houseType'];
         if (!empty($HouseInfo['info'])) {
             isset($HouseInfo['info']->isQuality) && ($param['is_quality'] = $HouseInfo['info']->isQuality);
             isset($HouseInfo['info']->isExquisite) && ($param['is_exquisite'] = $HouseInfo['info']->isExquisite);
         }
         $param['member_id'] = $HouseInfo['base']->memberId;
         $param['spread_type'] = $spreadType;
         return $this->saveBluewhaleHouse($houseId, $date, $spreadId, $param);
     }
     return false;
 }
コード例 #3
0
 public static function checkJpParams($params)
 {
     if (empty($params[self::PLANID]) || empty($params[self::BROKERID])) {
         self::$msg = '传入参数有误';
         return false;
     }
     self::$spreadId = $params[self::PLANID];
     self::$brokerId = $params[self::BROKERID];
     self::$spreadInfo = $spreadInfo = Model_Plan_Jp::getPlanInfoByPk(self::$spreadId);
     self::$houseInfo = Bll_House_JpHouseInfo::getHouseInfoById($spreadInfo->houseId);
     if (empty($spreadInfo) || Model_Plan_Jp::BIDVERSION_CHOICE != $spreadInfo->bidVersion) {
         self::$msg = '该计划不属于精选房源计划';
         return false;
     }
     return true;
 }
コード例 #4
0
ファイル: Choice.php プロジェクト: emilymwang8/ajk-broker
 /**
  * 金铺-精选房源管理页面
  * 返回值 为页面参数,所以必须是数组
  *
  * @param int $ajkBrokerId
  * @param int $cityId
  * @param array $extraData $request->get_parameters();
  * @return array
  */
 public static function jp_init_manage($ajkBrokerId, $cityId, $extraData = array())
 {
     //$jpBrokerInfo = Model_Broker_JpBroker::getJpBrokerInfoByAjkBrokerId($ajkBrokerId);
     $arrBidSpreadData = Model_Plan_Jp::getBidChoiceInfoEx($cityId, $ajkBrokerId);
     $isSpreadFull = count($arrBidSpreadData) >= self::ALL_JP_PLAN_NUM ? 1 : 0;
     $houseInfoArr = array();
     foreach ($arrBidSpreadData as $spread) {
         $houseId = $spread->houseId;
         //计划Id
         $spreadId = $spread->id;
         //状态
         $status = $spread->status;
         $planOverStatus = $status;
         if ($status == 4 || $status == 3) {
             $status = 14;
         }
         $houseInfoArr[$status][$houseId]['spreadId'] = $spreadId;
         $lChargeSum = Model_Payment_ChargeSum::data_access()->filter('spread_id', $spreadId)->find_only();
         //$clickSum = empty($lChargeSum) ? 0 : $lChargeSum->click_sum;
         $clickSum = Bll_House_JpHouseInfo::get_today_click_info_by_house($houseId);
         $costSum = empty($lChargeSum) ? 0 : $lChargeSum->cost_sum;
         $houseInfoArr[$status][$houseId]['clickSum'] = $clickSum;
         $houseInfoArr[$status][$houseId]['initBudget'] = sprintf('%.2f', $spread->budget / 100);
         $houseInfoArr[$status][$houseId]['budget'] = sprintf('%.2f', ($spread->budget - $costSum) / 100);
         $statusText = Bll_House_JpHouseInfo::formatHouseSpreadStatus($status, $spread);
         $houseInfoArr[$status][$houseId]['status'] = $status;
         $houseInfoArr[$status][$houseId]['planOverStatus'] = $planOverStatus;
         $houseInfoArr[$status][$houseId]['statusText'] = $statusText;
         $houseRelation = Bll_House_JpHouseInfo::getHouseInfoById($houseId);
         $houseType = $houseRelation['houseType'];
         $houseObj = $houseRelation['info'];
         //点击单击
         $houseInfoArr[$status][$houseId]['unit_price'] = sprintf('%.2f', $houseObj->spreadOffer / 100);
         $houseInfoArr[$status][$houseId]['isExquisite'] = $houseObj->isExquisite;
         $houseInfoArr[$status][$houseId]['houseTypeDesShort'] = Bll_House_JpHouseInfo::$arrHouseTypeDes['short'][$houseType];
         $houseInfoArr[$status][$houseId]['title'] = $houseObj->title;
         $houseInfoArr[$status][$houseId]['area'] = $houseObj->area;
         $houseInfoArr[$status][$houseId]['floor_info'] = Bll_House_JpHouseInfo::getHouseFloorInfo(self::convertObjToArray($houseObj), $houseType);
         $houseInfoArr[$status][$houseId]['property_name'] = Bll_House_JpHouseInfo::getHousePropertyName($houseRelation['info'], $houseType);
         $houseInfoArr[$status][$houseId]['url'] = Uri_JPHouse::build_index($cityId, $houseType) . $houseId;
         $houseInfoArr[$status][$houseId]['house_type'] = $houseType;
         $houseInfoArr[$status][$houseId]['price_info'] = Bll_House_JpHouseInfo::getHousePriceInfo(self::convertObjToArray($houseObj), $houseType);
     }
     ksort($houseInfoArr);
     $pageAttributes['isSpreadFull'] = $isSpreadFull;
     $pageAttributes['houseInfo'] = $houseInfoArr;
     return $pageAttributes;
 }
コード例 #5
0
ファイル: JpRank.php プロジェクト: emilymwang8/ajk-broker
 /**
  * 获取排名信息
  * @static
  * @param $p_intHouseId
  * @param $p_intOffer 单位:分
  * @param int $p_intHouseType
  * @param bool $p_bolReAll 是否返回全部信息:指定的排名&竞价几率 true-是,false-否(默认)
  * @param string $p_strReType 返回的数据类别 'rank_show'-展示排名(默认),'rank_pre'-预测排名,'rank_deduct'-扣费排名,'block_probability'-指定rank类别下(商圈|板块)竞价几率,'district_probability'-指定rank类别下区域竞价几率
  * @param &$p_arrOthRtnInfo 可以指定返回其他信息(免了重复算取信息):array('house'=>0,'price'=>0,'district_block'=>0,'next_offer'=>0) 1-返回该数据,0-不返回该数据
  * @return bool|int
  */
 public static function getRankingByHouse($p_intHouseId, $p_intOffer = 0, $p_intHouseType = 0, $p_bolReAll = false, $p_strReType = 'rank_show', &$p_arrOthRtnInfo = null)
 {
     $p_intHouseId = intval($p_intHouseId);
     $p_intHouseType = intval($p_intHouseType);
     $bolRtnNextOffer = isset($p_arrOthRtnInfo['next_offer']) && $p_arrOthRtnInfo['next_offer'] ? true : false;
     //返回下一名出价信息
     $bolRtnPrice = isset($p_arrOthRtnInfo['price']) && $p_arrOthRtnInfo['price'] ? true : false;
     //返回价格信息
     $bolRtnBlock = isset($p_arrOthRtnInfo['district_block']) && $p_arrOthRtnInfo['district_block'] ? true : false;
     //返回区域(板块|商圈)信息
     $bolRtnHouse = isset($p_arrOthRtnInfo['house']) && $p_arrOthRtnInfo['house'] ? true : false;
     //返回房源信息
     $bolRtnSpreadRaito = isset($p_arrOthRtnInfo['ratio']) && $p_arrOthRtnInfo['ratio'] ? true : false;
     //返回竞价系数
     $houseInfo = Bll_House_JpHouseInfo::getHouseInfoById($p_intHouseId);
     $objHouseIdx = $houseInfo['base'];
     $objHouse = $houseInfo['info'];
     $intHouseType = $houseInfo['HouseType'];
     $intCityId = $objHouse->city_id;
     $intBidSpreadId = !empty($objHouseIdx->bidSpreadId) ? $objHouseIdx->bidSpreadId : 0;
     if (!$p_intOffer) {
         $p_intOffer = $objHouse->spreadOffer;
     }
     if ($p_bolReAll) {
         $arrRst = array('rank' => 0, 'dis_probability' => array('block' => 0, 'block_max' => 0, 'district' => 0, 'district_max' => 0));
     }
     if ($bolRtnHouse) {
         $p_arrOthRtnInfo['house'] = (object) array_merge((array) $objHouseIdx, (array) $objHouse);
     }
     //获取区域板块
     $intBlockID = $intNewBusinessId = $intDistrictID = $intNewDistrictID = 0;
     $arrRegion = self::getDistrictBlock($intHouseType, $objHouse);
     if (isset($arrRegion['block_id'])) {
         $intBlockID = intval($arrRegion['block_id']);
     }
     if (isset($arrRegion['new_business_id'])) {
         $intNewBusinessId = intval($arrRegion['new_business_id']);
     }
     if (isset($arrRegion['district_id'])) {
         $intDistrictID = intval($arrRegion['district_id']);
     }
     if (isset($arrRegion['new_district_id'])) {
         $intNewDistrictID = intval($arrRegion['new_district_id']);
     }
     if ($bolRtnBlock) {
         $p_arrOthRtnInfo['district_block'] = $arrRegion;
     }
     //获取价格区间
     $arrPriceInfo = self::getPrice($intCityId, $intHouseType, $objHouse);
     $intPriceId = $arrPriceInfo['price_id'];
     $intPriceRangeCnt = $arrPriceInfo['total_cnt'];
     if ($bolRtnPrice) {
         $p_arrOthRtnInfo['price'] = $arrPriceInfo;
     }
     //查询(商圈|板块)+价格排名 | rank_deduct || rank_show || rank_pre
     $arrRankInfo = null;
     if ($p_strReType == 'rank_deduct') {
         //扣费排名
         $arrRankInfo = self::getBidRankByHid($p_intHouseId, $intHouseType, $intBidSpreadId, $intBlockID, 0, $intPriceId);
     } elseif ($p_strReType == 'rank_show') {
         //展示已有排名
         $arrRankInfo = self::getBidRankByHid($p_intHouseId, $intHouseType, $intBidSpreadId, $intBlockID, $intNewBusinessId, $intPriceId);
     } else {
         //预测排名
         //todo test
         $debug_info = '---------房源信息----------' . "\n";
         $debug_info .= '房源:' . $p_intHouseId . "\n";
         $debug_info .= '推广中的计划ID:' . $intBidSpreadId . "\n";
         $debug_info .= '类别:' . $intHouseType . "\n";
         $debug_info .= '板块ID:' . $intBlockID . "\n";
         $debug_info .= '新商圈ID:' . $intNewBusinessId . "\n";
         $debug_info .= '区域ID:' . $intDistrictID . "\n";
         $debug_info .= '新区域ID:' . $intNewDistrictID . "\n";
         $debug_info .= '出价:' . $p_intOffer . "分\n";
         $debug_info .= '出价时间:' . date('Y-m-d H:i:s', $objHouse->spread_offer_time) . "\n";
         $debug_info .= '价格段ID:' . $intPriceId . "\n";
         $arrRankInfo->spread_rank = 0;
         if ($intBidSpreadId) {
             $objOnline = self::getSpreadOnline($intBidSpreadId);
         }
         $fSpreadRatio = self::spreadRatio($p_intHouseId, $p_intOffer, $intBidSpreadId, $intCityId, $intHouseType, $intBlockID, $intNewBusinessId, $intPriceId, $objHouseIdx->property_id);
         $arrRankInfo->spread_rank = self::getBidRankPreByHid($intCityId, $intHouseType, $intBlockID, $intNewBusinessId, $intPriceId, floatval($fSpreadRatio));
         if ($bolRtnSpreadRaito) {
             $arrRst['ratio'] = $fSpreadRatio;
         }
         //如果已经有排名,且在大于当前预计排名的范围,则剔除
         if (!empty($objOnline) && $objOnline->spread_ratio >= $fSpreadRatio) {
             $arrRankInfo->spread_rank = $arrRankInfo->spread_rank - 1;
             $debug_info .= '[当前<=原竞价系数]' . "\n";
             //多名同竞价系数排序 待自测!
         }
         //当大于当前系数的名次刚好是自己的时候,预测排名为1
         $arrRankInfo->spread_rank = $arrRankInfo->spread_rank ? $arrRankInfo->spread_rank : 1;
         $debug_info .= '【预测排名】:' . $arrRankInfo->spread_rank . "\n";
         self::showDebug($debug_info);
     }
     /*这里是个坑
      *$arrRankInfo有可能是对象也有可能是数组
      * 以下是临时解决方案
      */
     $intRank = !empty($arrRankInfo) && isset($arrRankInfo->spread_rank) ? $arrRankInfo->spread_rank : 0;
     if (empty($intRank)) {
         $intRank = isset($arrRankInfo['spread_rank']) ? $arrRankInfo['spread_rank'] + 1 : 0;
     }
     if ($p_bolReAll) {
         $arrRst['rank'] = $intRank;
     } elseif ($p_strReType == 'rank_deduct' && !$bolRtnNextOffer || $p_strReType == 'rank_show' || $p_strReType == 'rank_pre') {
         return $intRank;
     } elseif ($p_strReType == 'rank_deduct' && $bolRtnNextOffer) {
         //返回排名及下一名信息
         $intNextOffer = self::getNextOffer($p_intHouseId, $intBlockID, $intPriceId);
         return array('house_id' => $p_intHouseId, 'rank' => $intRank, 'offer' => $objHouse->spread_offer, 'nextoffer' => $intNextOffer);
     }
     //查询(商圈|板块)下展示概率和最大展示概率 | block_probability
     if ($p_bolReAll || $p_strReType == 'block_probability') {
         $arrDisPInfo['block'] = self::getBidDisProbability($intCityId, $intRank, $intBlockID, $intNewBusinessId, $intPriceId, intval($intPriceRangeCnt), $p_intHouseId, $intHouseType, '板块');
         $arrDisPInfo['block_max'] = self::getBidDisProbability($intCityId, 1, $intBlockID, $intNewBusinessId, $intPriceId, intval($intPriceRangeCnt), $p_intHouseId, $intHouseType, '板块最大');
     }
     if ($p_bolReAll) {
         $arrRst['dis_probability']['block'] = $arrDisPInfo['block'];
         $arrRst['dis_probability']['block_max'] = $arrDisPInfo['block_max'];
     } elseif ($p_strReType == 'block_probability') {
         return $arrDisPInfo;
     }
     //查询区域下展示概率和最大展示概率 | district_probability
     if ($p_bolReAll || $p_strReType == 'district_probability') {
         $intTotalBlocks = self::getDistrictAllBlocks($intHouseType, $intDistrictID, $intNewDistrictID);
         $intPriceRangeCntAll = $intTotalBlocks * intval($intPriceRangeCnt);
         $arrDisPInfo['district'] = self::getBidDisProbability($intCityId, $intRank, $intBlockID, $intNewBusinessId, $intPriceId, intval($intPriceRangeCntAll), $p_intHouseId, $intHouseType, '区域');
         $arrDisPInfo['district_max'] = self::getBidDisProbability($intCityId, 1, $intBlockID, $intNewBusinessId, $intPriceId, intval($intPriceRangeCntAll), $p_intHouseId, $intHouseType, '区域最大');
     }
     if ($p_bolReAll) {
         $arrRst['dis_probability']['district'] = $arrDisPInfo['district'];
         $arrRst['dis_probability']['district_max'] = $arrDisPInfo['district_max'];
     } elseif ($p_strReType == 'district_probability') {
         return $arrDisPInfo;
     }
     return $arrRst;
 }
コード例 #6
0
 public static function JpBidEffectRank($bidPlanIds, $ajkBrokerId)
 {
     if (empty($p_arrSpreadIDs)) {
         return array();
     }
     $arrRtn = $arrSpreadIDs = array();
     $objRankBll = BLL_Spread_SpreadRankBLL::get_instance();
     $objHp = new BLL_Spread_HpManage();
     $objClickBll = Bll_Pay_ClickLogBll::get_instance();
     $jpMemberId = Model_Broker_JpBroker::getJpBrokerInfoByAjkBrokerId($ajkBrokerId);
     $memberId = $jpMemberId->id;
     //取计划信息
     $objModelSp = Model_Plan_Jp::data_access();
     $objSpreads = $objModelSp->find_by_pks($bidPlanIds);
     if (!empty($objSpreads)) {
         foreach ($objSpreads as $objSp) {
             //要返回的数据
             $arrRtnEle = array('hid' => $objSp->house_id, 'spreadid' => $objSp->id, 'rank' => 0, 'click' => 0, 'cost' => 0, 'is_stop' => 0);
             $arrSpreadIDs[] = $objSp->id;
             //已经暂停的计划
             if ($objSp->status == 4) {
                 $arrRtnEle['is_stop'] = 1;
             } elseif ($objSp->status == 3) {
                 $arrRtnEle['is_stop'] = -1;
             }
             //依据计划id获取
             try {
                 $objModelH = Model_House_JpHouseIdx::data_access();
                 $objHouse = $objModelH->filter('member_id', $memberId)->filter('bid_spread_id', $objSp->id)->find_only();
                 unset($objModelH);
             } catch (Exception $e) {
                 $objHouse = null;
             }
             //若不在计划中,按房源id获取
             if (empty($objHouse) && $objSp->house_id) {
                 try {
                     $objModelH = Model_House_JpHouseIdx::data_access();
                     $objHouse = $objModelH->find_by_pk($objSp->house_id);
                     unset($objModelH);
                 } catch (Exception $e) {
                     $objHouse = null;
                 }
             } else {
                 $arrRtnEle['hid'] = $objHouse->id;
             }
             //根据房源信息获取竞价中房源的排名
             if (!empty($objHouse) && $objHouse->bidSpreadId) {
                 $objHouseInfo = Bll_House_JpHouseInfo::getHouseInfoById($objHouse->id);
                 $arrRtnEle['rank'] = Bll_Plan_JpRank::getRankingByHouse($objHouse->id, $objHouseInfo['info']->spreadOffer, $objHouse->houseType, false, 'rank_show');
                 if (!$arrRtnEle['rank'] && $objHouse->bidSpreadId) {
                     $arrRtnEle['rank'] = Bll_Plan_JpRank::getRankingByHouse($objHouse->id, $objHouseInfo['info']->spreadOffer, $objHouse->houseType, false, 'rank_pre');
                 }
             }
             //根据房源ID获取竞价计划的今日点击
             $arrRtnEle['click'] = 0;
             if (!empty($objHouse)) {
                 $arrClick_t = $objClickBll->get_today_click_info_by_house($objHouse->id, 2, date("Ymd"));
                 //当日数据
                 $arrRtnEle['click'] = $arrClick_t;
             }
             $arrRtn[] = $arrRtnEle;
         }
         //根据计划ID获取竞价中计划的总花费
         if (!empty($arrSpreadIDs)) {
             $arrPayLog = $objHp->getPayLogBySpreadIDs($arrSpreadIDs);
             foreach ($arrRtn as $key => $arrData) {
                 if (isset($arrPayLog[$arrData['spreadid']])) {
                     $arrData['cost'] = $arrPayLog[$arrData['spreadid']]['cost_sum'];
                 } else {
                     $arrData['cost'] = 0;
                 }
                 $arrRtn[$key] = $arrData;
             }
         }
     }
     return $arrRtn;
 }
コード例 #7
0
ファイル: JpHouse.php プロジェクト: emilymwang8/ajk-broker
 /**
  * 房源手动取消套餐推广
  */
 public function do_cancelHouseCombo()
 {
     $tempHouseIds = explode(',', $this->params['houseIds']);
     $houseIds = array();
     foreach ($tempHouseIds as $k => $houseId) {
         $house = Bll_House_JpHouseInfo::getHouseInfoById($houseId);
         if ($house['base']['memberId'] != $this->jpBrokerId) {
             continue;
         }
         $houseComboInfo = Model_Combo_HouseRelation::data_access('jp')->filter('houseId', $house['base']->id)->find_only();
         if ($houseComboInfo->state != Model_Combo_HouseRelation::ENUM_HOUSE_ONLINE) {
             continue;
         }
         $houseIds[] = $houseId;
     }
     if (empty($houseIds)) {
         $this->outPut(0, '房源信息有误,请重新选择房源');
     }
     if (Bll_Combo_HouseRelation::houseStopComboSpread($this->brokerId, $this->cityId, $tempHouseIds, Bll_Combo_HouseRelation::SITE_TYPE_JP)) {
         $this->outPut(1, '房源停止推广成功');
         /*
         foreach($houseIds as $houseId) {
             $houseIdx = Model_House_JpHouseIdx::data_access()
                 ->filter('id', $houseId)
                 ->filter('isDelete', Model_House_JpHouseIdx::ENUM_IS_DELETE_NO)
                 ->find_only();
             //删除竞价 更新数据 通知solr后端JOB做
             if($houseIdx->bidSpreadId) {
                 $plan = Model_Plan_Jp::data_access()
                     ->filter('id', $houseIdx->bidSpreadId)
                     ->find_only();
                 if($plan) {
                     $houseIdx->bidSpreadId = 0;
                     $houseIdx->updateTime = date('Y-m-d H:i:s');
                     $houseIdx->save();
         
                     if($plan->status = Model_Plan_Jp::ENUM_STATUS_ONLINE) {
                         //发送结算
                         $params = array();
                         $params['spread_id'] = $plan->id;
                         $params['log_status'] = 7;
                         Bll_Plan_Bid_JpSettlement::getInstance()->settlement($params,'bid');
                     }
         
                     $plan->status = Model_Plan_Jp::ENUM_STATUS_OVER;
                     $plan->isDelete = 1;
                     $plan->updateTime = date('Y-m-d H:i:s');
                     $plan->save();
         
                     //记录房源操作
                     $intTitle = Const_CrmHouseLog::V_OPERATION_TITLE_OUT_SHELVES;
                     $intComment = Const_CrmHouseLog::V_OPERATION_COMMENT_HOUSE_SPREAD_OFFLINE;
                     Bll_Log_JpHouse::getInstance()->logHouseOperation($houseIdx->id,$houseIdx->memberId,$intTitle,$intComment);
                     //TO 初始化房源统计日志
                     Bll_House_JpBwAnalysis::getInstance()->openSaveBluewhaleHouse($houseIdx->id,date('Y-m-d'),$houseIdx->bidSpreadId,$plan->type);
                 }
             }
         }
         */
     } else {
         $this->outPut(0, '房源停止推广失败');
     }
 }