public function handle_request()
 {
     $cursor = $this->getFlag();
     if (empty($cursor['id'])) {
         $cursor['id'] = 0;
     }
     $i = 0;
     while ($i < self::CIRCOUNT) {
         $i++;
         //读取bi数据
         $data = Model_Stats_HzPropQuality::data_access()->filter_by_op('id', '>', $cursor['id'])->limit(self::LIMIT)->get_all();
         if (empty($data)) {
             $this->setShStopFlag();
             return false;
         }
         //更新游标
         $cursor['id'] = $data[self::LIMIT - 1]['id'];
         $this->setFlag($cursor);
         //设置log
         $log = array('time' => date('Ymd h:i:s'), 'id' => $cursor['id']);
         $this->setLog(json_encode($log));
         $propIds = array();
         foreach ($data as $k => $v) {
             $propIds[] = $v['proId'];
         }
         //取出表中已存在的propId
         $extPropIds = Model_Activity_Res_HaoZuPropQualitys::data_access()->load_field('propId')->filter_by_op('propId', 'in', $propIds)->get_all();
         $tmp = array();
         foreach ($extPropIds as $v) {
             $tmp[$v['propId']] = $v['propId'];
         }
         //将不存在的propId插入表中
         foreach ($data as $k => $v) {
             if (empty($tmp[$v['proId']])) {
                 $insertData = array('propId' => $v['proId'], 'logTime' => date("Ymd"), 'cityId' => $v['cityId'], 'rankStar' => $v['rank'], 'createTime' => $v['creDate'], 'dataFrom' => 0);
                 Model_Activity_Res_HaoZuPropQualitys::insertData($insertData);
             }
         }
         unset($data);
     }
 }
Exemple #2
0
 public static function getRankFromBrokerBI($propIds)
 {
     $resultTmp = array();
     $resultTmpA = $resultTmpB = array();
     //从经纪人表中获取rank
     $resultTmpA = Model_Activity_Res_HaoZuPropQualitys::getPropRank($propIds);
     //取出在经纪人表中没有rank的propId
     $tmp = array();
     $propIdsTmp = array();
     foreach ($resultTmpA as $v) {
         $propIdsTmp[] = $v['propId'];
     }
     foreach ($propIds as $v) {
         if (!in_array($v, $propIdsTmp)) {
             $tmp[] = $v;
         }
     }
     //如果全部的房源都取得rank,直接返回
     if (empty($tmp)) {
         return $resultTmpA;
     }
     //读取BI中的房源
     $resultTmpB = Model_Stats_HzPropQuality::getPropsquality($tmp);
     if (!isset($resultTmpB)) {
         return $resultTmpA;
     }
     $resultTmp = $resultTmpA;
     $tmp = array();
     foreach ($resultTmpB as $v) {
         $tmp = array('propId' => $v['proId'], 'logTime' => date("Y-m-d", time()), 'cityId' => $v['cityId'], 'rankStar' => $v['rank'], 'createTime' => $v['creDate'], 'dataFrom' => 0);
         Model_Activity_Res_HaoZuPropQualitys::insertData($tmp);
         $resultTmp[] = $tmp;
     }
     return $resultTmp;
 }
 private static function preparePropInfo(&$out)
 {
     // 获取房源
     $propResult = Bll_House_HzHouse::getPropInfo($out['proId'], $out['cityId'], 3);
     if (!$propResult['status']) {
         throw new Exception($propResult['msg']);
     }
     $propInfo = $propResult['msg'];
     // 检查并拼接违规信息
     $illegalInfo = Bll_HzProp::checkAndGetPropsIllegalInfos(array($out['proId'] => $propInfo));
     $propInfo = $illegalInfo[$out['proId']];
     // 获取剩余时间
     $propInfo['leftDays'] = Bll_House_HzHouse::getLeftDays($propInfo['created']);
     // 获取房源图片数
     $imageInfo = Bll_House_HzHouse::getPropImages($out['proId']);
     $propInfo['imageInfo'] = $imageInfo;
     // 房源默认图片 (默认优先封面图 -》 第一张室内图 -》 房型)
     //$propInfo['propDefaultImg'] = Bll_House_HzHouse::getPropDefaultImgWithUrl($out['proId']);
     $propInfo['propDefaultImg'] = self::getThumbImg($imageInfo);
     // 获取房源可优化项
     $propInfo['canImproveItems'] = self::getPropCanImproveItems($propInfo, $imageInfo);
     // 是否手机发房
     $propInfo['isMobile'] = isset($propInfo['from']) ? Bll_House_HzHouse::isMobileProp($propInfo['from']) : false;
     // 此房源全部点击数据
     $propInfo['propAllClick'] = Model_Stats_PropClick::getPropAllClicks($out['proId'], $out['hzBrokerId'], $out['cityId']);
     // 此房源全部曝光数据
     $propInfo['propAllShow'] = Bll_House_HzHouse::getPropShow($out['proId'], $out['cityId']);
     // 此房源质量
     $propQuality = Model_Stats_HzPropQuality::getPropsquality($out['proId']);
     $propInfo['propsQuality'] = $propQuality ? $propQuality[$out['proId']] : array();
     // 根据blockid 获取对应code
     $areaInfo = Model_City_HzArea::getAreaById($propInfo['blockid']);
     $propInfo['typeCode'] = $areaInfo['typeCode'];
     return $propInfo;
 }
 /**
  * 组装未推广列表 取出所有-有效定价房源
  * @param $out
  * @return array
  */
 private static function prepareOutList(&$out)
 {
     $outList = array();
     $outPropIds = array();
     $fixProIds = array_keys($out['props']);
     // 取出经纪人所有非删除房源 (分表)
     $allSearchProps = Model_House_HzPropSearch::getPropLists($out['cityId'], array(array('ajkBrokerId', '=', $out['ajkBrokerId']), array('status', '<>', Const_HzStatus::DELETE), array('status', '<>', Const_HzStatus::OFFLINE), array('status', '<>', Const_HzStatus::OUTPORT), array('status', '<>', Const_HzStatus::HIBERNATE), array('status', '<>', Const_HzStatus::REMOVE), array('status', '<>', Const_HzStatus::EXPIRED)), 1000, array('created', 'desc'));
     if (empty($allSearchProps)) {
         return array();
     }
     // 获取城市价格段
     $allPrices = Model_House_HzPriceChoice::getAllPriceByCityId($out['cityId']);
     $out['getQualityProIds'] = array();
     foreach ($allSearchProps as $allSearchProp) {
         $proId = $allSearchProp['proid'];
         $out['getQualityProIds'][] = $proId;
         // 过滤非删除状态定价
         if (in_array($proId, $fixProIds)) {
             continue;
         }
         $outList[$proId] = $allSearchProp;
         // 获取剩余时间
         $outList[$proId]['leftDays'] = Bll_House_HzHouse::getLeftDays($allSearchProp['created']);
         $outPropIds[] = $proId;
     }
     // 获取改经纪人所有房源质量
     $out['propsQuality'] = Model_Stats_HzPropQuality::getPropsquality($out['getQualityProIds']);
     // 获取如是违规房源 拼接违规原因
     $outList = Bll_HzProp::checkAndGetPropsIllegalInfos($outList);
     // 批量获取主表信息
     if (empty($outPropIds)) {
         return array();
     }
     $props = Model_House_HzProp::getPropsByPropIds($outPropIds);
     if (!$props) {
         return array();
     }
     // 房源主分表信息合并
     foreach ($outList as $proId => $outProp) {
         $outList[$proId] = array_merge($outList[$proId], $props[$proId]);
         // 计算点击价格
         if (!empty($allPrices)) {
             foreach ($allPrices as $priceInfo) {
                 if ($priceInfo['lower'] < $outList[$proId]['pricenum'] && $priceInfo['upper'] >= $outList[$proId]['pricenum']) {
                     $outList[$proId]['unitPrice'] = $priceInfo['price'];
                     break;
                 }
             }
         }
     }
     return $outList;
 }