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);
     }
 }
Beispiel #2
0
 /**
  * 获取坑位的准确usedNum
  */
 public static function countBucketChoicePlan($blockId, $newBlockId, $houseType, $priceId)
 {
     $objModel = Model_Plan_Jp::data_access()->force_master();
     if ($newBlockId) {
         $countObj = $objModel->filter('newBlockId', $newBlockId)->filter('houseType', $houseType)->filter('priceId', $priceId);
     } else {
         $countObj = $objModel->filter('blockId', $blockId)->filter('houseType', $houseType)->filter('priceId', $priceId);
     }
     $count = $countObj->filter('type', Model_Plan_Jp::ENUM_TYPE_BID)->filter('bidVersion', Model_Plan_Jp::BIDVERSION_CHOICE)->filter('isDelete', Model_Plan_Jp::ENUM_IS_DELETE_NO)->filter('status', array(2, 6))->count();
     return $count;
 }
Beispiel #3
0
 public static function stopJpBidData($list)
 {
     $checkList = self::checkList($list);
     if (!$checkList['status']) {
         return $checkList;
     }
     $planInfo = Model_Plan_Jp::data_access()->filter('id', $list['planId'])->find_only();
     if ($planInfo->isDelete == Model_Plan_Jp::ENUM_IS_DELETE_YES) {
         return Bll_HzPropBll::build_return(0, '无效的竞价计划' . json_encode($list));
     }
     if ($planInfo->status != Model_Plan_Jp::ENUM_STATUS_ONLINE) {
         return Bll_HzPropBll::build_return(0, '竞价计划不在推广中' . json_encode($list));
     }
     if ($planInfo->type != Model_Plan_Jp::ENUM_TYPE_BID) {
         return Bll_HzPropBll::build_return(0, '竞价计划类型有误' . json_encode($list));
     }
     if (!in_array($planInfo->bidVersion, array(Model_Plan_Jp::BIDVERSION_OLD, Model_Plan_Jp::BIDVERSION_CHOICE))) {
         return Bll_HzPropBll::build_return(0, '竞价计划version error' . json_encode($list));
     }
     $houseIdx = Model_House_JpHouseIdx::data_access()->filter('id', $planInfo['houseId'])->find_only();
     if (empty($houseIdx)) {
         return Bll_HzPropBll::build_return(0, '金铺房源信息没有' . json_encode($list));
     }
     if ($houseIdx->bidSpreadId != $planInfo->id) {
         return Bll_HzPropBll::build_return(0, '金铺房源信息有误bidSpreadId' . json_encode($list));
     }
     $houseIdx->bidSpreadId = 0;
     if (!$houseIdx->save()) {
         return Bll_HzPropBll::build_return(0, '金铺房源信息更新失败' . json_encode($list));
     }
     //发送结算
     $params = array();
     $params['spread_id'] = $planInfo->id;
     $params['log_status'] = 7;
     Bll_Plan_Bid_JpSettlement::getInstance()->settlement($params, 'bid');
     $planInfo->status = Model_Plan_Jp::ENUM_STATUS_OVER;
     $planInfo->isDelete = 1;
     $planInfo->updateTime = date('Y-m-d H:i:s');
     if (!$planInfo->save()) {
         return Bll_HzPropBll::build_return(0, '金铺计划信息更新失败' . json_encode($list));
     }
     //房源下架tosolr
     Bll_House_JpHouseInfo::updateHouseToSolr(1, $planInfo->houseId, 1);
     //通知更新q_spread_bid_update表 计算竞价系数
     Model_Plan_JpSpreadBidUpdate::setBidUpdateQ($planInfo->id);
     //记录房源日志
     $data = array('houseId' => $houseIdx->id, 'planId' => $planInfo->id, 'brokerId' => $list['brokerId'], 'cityId' => $planInfo->cityId, 'type' => 15, 'changeType' => 407, 'remark' => '房源' . $houseIdx->id . '移出定价计划/取消套餐推广。竞价' . $planInfo->id . '(id)取消竞价推广。', 'addDate' => date('Y-m-d H:i:s'), 'operatorId' => $list['operationId'], 'siteType' => 3);
     if (!Model_Log_HouseLogNew::create($data, date('Ymd'))->save()) {
         return Bll_HzPropBll::build_return(0, array("日志写入失败"));
     }
     return Bll_HzPropBll::build_return(1, array('竞价' . $planInfo->id . '(id)取消竞价推广。'));
 }
 public function DownHouse($brokerId = 0, $promitionHouseNum = 0)
 {
     $brokerId = intval($brokerId);
     $promitionHouseNum = intval($promitionHouseNum);
     if ($brokerId == 0 || $promitionHouseNum == 0) {
         return false;
     }
     //将二手房经纪人ID转成商业地产ID
     $jpBrokerInfoObj = Model_Broker_JpBroker::getJpBrokerInfoByAjkBrokerId($brokerId);
     if (!$jpBrokerInfoObj || $jpBrokerInfoObj->id == 0) {
         return Util_GlobalFunc::buildReturn(0, "该经纪人:{$brokerId}没有找到");
     }
     //获取这个经纪人的有效计划
     $OnlinePlan = Model_Plan_Jp::getOnlinePlanByMemberId($jpBrokerInfoObj->id);
     if (!$OnlinePlan) {
         return Util_GlobalFunc::buildReturn(0, "该经纪人:{$brokerId}没有有效计划");
     }
     $onlineplan = array();
     foreach ($OnlinePlan as $plan) {
         $onlineplan[] = $plan->id;
         $isBidVersion[$plan->id]['bidVersion'] = $plan->bidVersion;
     }
     //获取这些有效计划下的房子
     $houseIdx = Model_House_JpHouseIdx::getHouseInfoByFixPlanId($onlineplan);
     if (!$houseIdx) {
         return Util_GlobalFunc::buildReturn(0, "该经纪人:{$brokerId}有效计划下的房子");
     }
     $housecount = count($houseIdx);
     echo '正在处理商业地产' . $brokerId . ',总推广房源数' . $housecount . ',api中允许推广数量' . $promitionHouseNum;
     $allReturn = array();
     //和套餐的推广房源做比较,如果当前在线推广的房子大于套餐推广房子,则下房源将较早推广的房子下架
     if ($housecount > $promitionHouseNum) {
         $offNum = $housecount - $promitionHouseNum;
         for ($i = $offNum; $i >= 1; $i--) {
             if (empty($houseIdx[$i])) {
                 continue;
             }
             if ($houseIdx[$i]->bidSpreadId) {
                 $resultBid = Bll_House_JpHouseInfo::removeBidHouseFromSpread($houseIdx[$i], $jpBrokerInfoObj->id, 1, false);
                 if (!$resultBid['success']) {
                     $allReturn[] = $resultBid['data'];
                 }
             }
             $resultFix = Bll_House_JpHouseInfo::removeFixHouseFromSpread($houseIdx[$i], $jpBrokerInfoObj->id);
             if (!$resultFix['success']) {
                 $allReturn[] = $resultFix['data'];
             }
         }
     }
     return Util_GlobalFunc::buildReturn(1, $allReturn);
 }
 public function updateSpreadStatus($spreadId = 0, $status = 0, $logStatus = 0)
 {
     if ($spreadId === 0 || $status === 0 || $logStatus === 0) {
         return false;
     }
     try {
         $spreadObj = Model_Plan_Jp::getPlanInfoByPk($spreadId);
         $spreadObj->status = $status;
         $flag1 = $spreadObj->save();
         $flag2 = Model_Log_JpSpreadStatusUpdate::writeSpreadStatusLog($status, $spreadId, $logStatus);
         if ($flag1 && $flag2) {
             return true;
         }
     } catch (Exception $e) {
     }
     return false;
 }
 public function handle_request()
 {
     $brokers = array();
     $dao = Model_Plan_Jp::data_access();
     if ($this->brokerid) {
         $dao->filter('memberId', $this->brokerid);
     }
     $dao->filter('cityId', $this->cityid);
     $dao->filter('type', 2);
     $dao->filter('status', 2);
     $dao->filter('isDelete', '0');
     $datas = $dao->find();
     foreach ($datas as $data) {
         $brokerid = $data['memberId'];
         if (isset($brokers[$brokerid])) {
             continue;
         }
         $result = Uri_Curl::get($this->url . 'jinpu/api/choice/brokerprop', array('brokerid' => $brokerid, 'status' => 5));
         printf('[%s]开始处理金铺: brokerId为 %s,处理结果:%s' . PHP_EOL, date('Y-m-d H:i:s'), $brokerid, $result);
         $brokers[$brokerid] = 1;
     }
 }
Beispiel #7
0
 protected static function init()
 {
     try {
         $idx = Model_House_JpHouseIdx::data_access()->find_by_pk(self::$houseId);
         self::$memberId = $idx->memberId;
     } catch (Exception $e) {
         self::$memberId = 0;
         $idx = null;
     }
     if (!$idx) {
         return false;
     }
     self::$houseType = $idx->houseType;
     self::$houseModelName = null;
     self::$houseImgModelName = NULL;
     self::get_houseModel();
     $houseModel = self::$houseModelName;
     try {
         $house = $houseModel::data_access()->find_by_pk(self::$houseId);
     } catch (Exception $e) {
     }
     self::$officeExquisite = 0;
     self::$shopHighQuality = 0;
     self::$publishTime = 0;
     self::$spreadOffer = 0;
     self::$cityId = $idx->cityId;
     self::$houseUnitPrice = 0;
     self::$price_75 = null;
     self::$exquisiteScore = 0;
     if ($house) {
         self::$exquisiteScore = $house->exquisiteScore;
         if (self::$houseCategory == 'office') {
             self::$officeExquisite = $house->isExquisite;
             if (self::$houseType == Model_House_JpHouseIdx::ENUM_HOUSE_TYPE_OFFICE_RENT) {
                 self::$houseUnitPrice = $house->dailyRent;
                 $midpricedata = self::get_midprice($house->buildingId);
                 self::$price_75 = !is_null($midpricedata) ? $midpricedata->mid_price_office_rent : null;
             } else {
                 self::$houseUnitPrice = $house->unitPrice;
                 $midpricedata = self::get_midprice($house->buildingId);
                 self::$price_75 = !is_null($midpricedata) ? $midpricedata->mid_price_office_sale : null;
             }
         } elseif (self::$houseCategory == 'shop') {
             self::$shopHighQuality = $house->isQuality;
             if (self::$houseType == Model_House_JpHouseIdx::ENUM_HOUSE_TYPE_SHOP_RENT) {
                 self::$houseUnitPrice = $house->dailyRent;
                 $midpricedata = self::get_midprice($house->propertyId);
                 self::$price_75 = !is_null($midpricedata) ? $midpricedata->mid_price_shop_rent : null;
             } else {
                 self::$houseUnitPrice = $house->unitPrice;
                 $midpricedata = self::get_midprice($house->propertyId);
                 self::$price_75 = !is_null($midpricedata) ? $midpricedata->mid_price_shop_sale : null;
             }
         }
         if ($house->createTime) {
             self::$publishTime = $house->createTime;
         }
         if ($house->spreadOffer) {
             self::$spreadOffer = $house->spreadOffer;
         }
     }
     if ($idx->spreadId == 0) {
         self::$spreadType = 0;
     } else {
         try {
             $spread = Model_Plan_Jp::data_access()->find_by_pk($idx->spreadId);
         } catch (Exception $e) {
         }
         if ($spread) {
             self::$spreadType = $spread->type;
         }
     }
     $objMember = Model_Broker_JpBroker::data_access()->find_by_pk($idx->memberId, false);
     if ($objMember && $objMember->hasRecharged) {
         self::$memberType = 2;
     }
     return true;
 }
 public function addFixPlan($params, $from = 'search')
 {
     //创建默认的定价计划
     // 根据memcache判断结果,如果大于1,则返回查询结果
     $objMemcache = APF_Cache_Factory::get_instance()->get_memcache();
     $memKey = __CLASS__ . '_' . __FUNCTION__ . '_' . $params['memberId'];
     $currentValue = $objMemcache->increment($memKey, 1);
     $isTop = Model_City_JpLimit::data_access()->filter('city_id', $params['cityId'])->get_row();
     $plans = Model_Plan_Jp::data_access()->force_master()->filter('memberId', $params['memberId'])->filter('cityId', $params['cityId'])->filter('type', 1)->filter('isDelete', 0)->get_all();
     //封顶城市 1个定价组
     if (!empty($plans) && $isTop) {
         return $from == 'search' ? $plans : array('status' => -1, 'info' => '封顶城市最多一个定价组');
     }
     if ($isTop && $isTop['status'] == 1 && $currentValue && $currentValue > 1) {
         //封顶城市
         $objMemcache->delete($memKey);
         return $from == 'search' ? $plans : array('status' => -1, 'info' => '封顶城市最多一个定价组');
     }
     //不封顶城市 最多5个定价组
     if (!empty($plans) && count($plans) >= 5) {
         return $from == 'search' ? $plans : array('status' => -2, 'info' => '最多5个定价组');
     }
     if ($params['budget'] > 1000 || $params['budget'] < 10) {
         return $from == 'search' ? $plans : array('status' => -3, 'info' => '定价推广组预算最多1000元,最少10元');
     }
     //创建计划流程开始
     $plan = array();
     $plan['memberId'] = $params['memberId'];
     $plan['budget'] = $params['budget'] * 100;
     $plan['name'] = $params['name'];
     $plan['cityId'] = $params['cityId'];
     $plan['serialNumber'] = 0;
     $plan['startTime'] = 0;
     $plan['endTime'] = 0;
     $plan['noBudgetDate'] = 0;
     $plan['createTime'] = date('Y-m-d H:i:s');
     $plan['updateTime'] = date('Y-m-d H:i:s');
     $plan['isDelete'] = 0;
     $plan['houseNum'] = 0;
     $plan['type'] = 1;
     //经纪人身份认证状态
     $memberCheckState = $this->getMemberCheckStatus($plan['memberId']);
     //判定账户余额
     $balance = $this->getMemberBalance($plan['memberId']);
     if (!$memberCheckState) {
         $status = 4;
         $stopReason = 3;
     } elseif ($balance <= 0) {
         $status = 4;
         $stopReason = 2;
     } else {
         $status = 2;
         $stopReason = 0;
     }
     $plan['status'] = $status;
     $plan['stopReason'] = $stopReason;
     $newPlanObj = Model_Plan_Jp::create($plan);
     $newPlanObj->save();
     $planId = $newPlanObj->id;
     $plan['id'] = $planId;
     return $from == 'search' ? array($plan) : array('status' => 1, 'info' => '创建计划成功');
 }
Beispiel #9
0
 public static function prepareBidList(&$out)
 {
     $out['bidHouses'] = array();
     //获取经纪人竞价计划
     $BidPlans = Model_Plan_Jp::data_access()->filter('memberId', $out['jpBrokerId'])->filter('type', Model_Plan_Jp::ENUM_TYPE_BID)->filter('isDelete', Model_Plan_Jp::ENUM_IS_DELETE_NO)->filter('bidVersion', Model_Plan_Jp::BIDVERSION_OLD)->get_all();
     $listInfo = $bidHouseIds = array();
     //排名 今日点击量 预算余额 采用页面加载后的ajax todo
     if ($BidPlans) {
         foreach ($BidPlans as $plan) {
             $houseInfo = $out['houses'][$plan['houseId']];
             if (empty($houseInfo['base']) || empty($plan)) {
                 continue;
             }
             $listInfo[$plan['houseId']]['houseInfo'] = $houseInfo;
             $listInfo[$plan['houseId']]['planInfo'] = $plan;
             $bidHouseIds[$plan['houseId']] = $plan['houseId'];
         }
     }
     foreach ($listInfo as $houseId => $mixInfo) {
         // 是否暂停
         if ($mixInfo['planInfo']['status'] == '4') {
             $is_stop_f = 1;
         } else {
             $is_stop_f = 0;
         }
         $is_stop[$houseId] = $is_stop_f;
     }
     array_multisort($is_stop, SORT_DESC, $bidHouseIds, SORT_DESC, $listInfo);
     $out['bidHouses'] = $listInfo;
     $out['bidHouseIds'] = $bidHouseIds;
 }
Beispiel #10
0
 /**
  * 把房源从竞价推广中移除
  * @param $objHouse
  * @param int $p_intMemberId
  * @param $log_type:1,手动停止 2,房源过期
  * @param int $do_choice  是否处理精选计划,如果为false 说明插入竞价队列表,在竞价队列JOB中处理
  * @return mixed
  */
 public static function removeBidHouseFromSpread($objHouse, $memberId = 0, $log_type = 1, $do_choice = true)
 {
     if ($log_type == 1) {
         $arr_log_param = array('spread_status' => Model_Log_JpSpreadStatusUpdate::ENUM_STATUS_SPREAD_STOP, 'house_log' => Model_Log_JpHouseUpDown::ENUM_BID_MEMBER_HOUSE_STOP);
     } elseif ($log_type == 2) {
         $arr_log_param = array('spread_status' => Model_Log_JpSpreadStatusUpdate::ENUM_STATUS_SPREAD_HOUSE_EXPIRE, 'house_log' => Model_Log_JpHouseUpDown::ENUM_JOB_HOUSE_EXPIRE);
     }
     $p_intHouseId = $objHouse->id;
     //检查推广信息
     $arrResult = Bll_Plan_JpPlanManage::getInstance()->checkSpreadInfo($objHouse->bidSpreadId, $memberId, $objHouse->id);
     if (!$arrResult['success']) {
         return $arrResult;
     }
     $objSpread = $arrResult['data'];
     //从竞价中移除房源
     if ($objSpread->type == Model_Plan_Jp::ENUM_TYPE_HP) {
         if ($objSpread->bidVersion == Model_Plan_Jp::BIDVERSION_CHOICE) {
             if (false == $do_choice) {
                 return array('success' => true, 'data' => '操作成功');
             }
         }
         //记录停止日志
         Bll_Log_JpPlan::getInstance()->writeSpreadStatusLog($arr_log_param['spread_status'], $objHouse->bidSpreadId, '房源停止计划:触发结算前');
         //发送结算
         $params = array();
         $params['spread_id'] = $objHouse->bidSpreadId;
         $params['log_status'] = 7;
         Bll_Plan_Bid_JpSettlement::getInstance()->settlement($params, 'bid');
         //解除关系
         $objHouse->bidSpreadId = 0;
         $objHouse->save();
         //判断是否下架房源
         $intXiaJia = 1;
         if (!empty($objHouse->fixSpreadId)) {
             $objModel = Model_Plan_Jp::data_access();
             try {
                 $objFixSpread = $objModel->find_by_pk($objHouse->fixSpreadId, false);
             } catch (Exception $e) {
                 $objFixSpread = null;
             }
             if (!empty($objFixSpread) && $objFixSpread->status == 2) {
                 $intXiaJia = 0;
             }
         }
         //操作下架
         if ($intXiaJia) {
             //下架房源
             self::updateHouseIsList($objHouse->id, $objHouse->houseType, 0);
             //记录房源操作
             $intTitle = Const_CrmHouseLog::V_OPERATION_TITLE_OUT_SHELVES;
             $intComment = Const_CrmHouseLog::V_OPERATION_COMMENT_HOUSE_SPREAD_OFFLINE;
             Bll_Log_JpHouse::getInstance()->logHouseOperation($objHouse->id, $objHouse->memberId, $intTitle, $intComment);
         }
         //更新solr
         Bll_House_JpHouseInfo::updateHouseToSolr(1, $p_intHouseId, 1);
         //TO 初始化房源统计日志
         Bll_House_JpBwAnalysis::getInstance()->openSaveBluewhaleHouse($objHouse->id, date('Y-m-d'), $objHouse->bidSpreadId, $objSpread->type);
         //竞价房源下线日志
         Bll_Log_JpHouse::getInstance()->writeHouseLog($objHouse->id, $objHouse->bidSpreadId, 0, $objHouse->memberId, $arr_log_param['house_log']);
         $objSpread->isDelete = 1;
         $objSpread->save();
         return array('success' => true, 'data' => '操作成功');
     }
 }
Beispiel #11
0
 public function dealTask($solrOnProId)
 {
     $houseInfo = Model_House_JpHouseIdx::data_access()->filter('id', $solrOnProId)->get_row();
     $brokerInfo = Model_Broker_JpBroker::data_access()->filter('id', $houseInfo['memberId'])->get_row();
     if ($houseInfo['isDelete'] == 1) {
         if ($this->dealFlag) {
             $result = Bll_Combo_NoticeSolrUpDown::noticeComboSolrJpAPI($this->cityId, $brokerInfo['ajkMemberId'], $solrOnProId, $houseInfo['houseType'], 2);
             $this->setLog(sprintf('房源 %s 通知中间件返回的结果status=%s ; message=%s' . PHP_EOL, $solrOnProId, $result['status'], $result['message']));
         }
         $this->setLog(sprintf('房源 %s 已经删除, 需要通知solr下' . PHP_EOL, $solrOnProId));
         return true;
     }
     //查询城市配置信息
     $ComboConfig = DAO_My_ComboConfig::getComboConfigByCityId($houseInfo['cityId']);
     if ($ComboConfig && $ComboConfig['type'] == 0) {
         //套餐城市
         if (!Bll_Combo_HouseRelation::getOnlineRelationByHouseId($solrOnProId, Bll_Combo_HouseRelation::SITE_TYPE_JP)) {
             if ($this->dealFlag) {
                 $result = Bll_Combo_NoticeSolrUpDown::noticeComboSolrJpAPI($this->cityId, $brokerInfo['ajkMemberId'], $solrOnProId, $houseInfo['houseType'], 2);
                 $this->setLog(sprintf('房源 %s 通知中间件返回的结果status=%s ; message=%s' . PHP_EOL, $solrOnProId, $result['status'], $result['message']));
             }
             $this->setLog(sprintf('房源 %s 不在套餐推广中, 需要通知solr下' . PHP_EOL, $solrOnProId));
             return true;
         }
         return true;
     } else {
         //ppc城市
         if ($houseInfo['spreadId'] != 0) {
             $spreadInfo = Model_Plan_Jp::data_access()->filter('id', $houseInfo['spreadId'])->filter('type', Model_Plan_Jp::ENUM_TYPE_FIX)->filter('isDelete', Model_Plan_Jp::ENUM_IS_DELETE_NO)->get_row();
             if ($spreadInfo && $spreadInfo['status'] == 2) {
                 return true;
             }
         }
         if ($this->dealFlag) {
             $result = Bll_Combo_NoticeSolrUpDown::noticeComboSolrJpAPI($this->cityId, $brokerInfo['ajkMemberId'], $solrOnProId, $houseInfo['houseType'], 2);
             $this->setLog(sprintf('房源 %s 通知中间件返回的结果status=%s ; message=%s' . PHP_EOL, $solrOnProId, $result['status'], $result['message']));
         }
         $this->setLog(sprintf('房源 %s 不在定价推广中, 需要通知solr下' . PHP_EOL, $solrOnProId));
         return true;
     }
 }
Beispiel #12
0
 /**
  *
  * 查询经纪人定价、竞价、精选计划
  *
  * @param $jpBroekrId
  * @param int $type 1-定价,2-竞价、精选
  * @param array $status 2-推广
  * @return array
  */
 public static function getPlanByMemberId($jpBroekrId, $type = 1, $status = array(2))
 {
     try {
         $houseInfo = Model_Plan_Jp::data_access()->filter('memberId', $jpBroekrId)->filter('type', $type)->filter('status', $status)->filter('isDelete', 0)->get_all();
         return $houseInfo;
     } catch (Exception $e) {
         return array();
     }
 }
Beispiel #13
0
 /**
  * 精选计划板块变更
  *
  * @param array $queueInfo
  * @return array
  */
 public static function houseBlockChange($queueInfo)
 {
     $choicePlanInfo = Model_Plan_Jp::getPlanInfoById($queueInfo['planId'], true);
     if (empty($choicePlanInfo)) {
         return self::buildReturn(0, '没有获取到计划');
     }
     if ($choicePlanInfo['status'] != Model_Plan_Jp::ENUM_STATUS_ONLINE && $choicePlanInfo['status'] != Model_Plan_Jp::ENUM_STATUS_CHOICE_HOLD) {
         return self::buildReturn(1, sprintf('计划状态[%d]不处理', $choicePlanInfo['status']));
     }
     /** 获取房源信息 */
     $houseInfo = Model_House_JpHouseIdx::getHouseInfoById($choicePlanInfo['houseId']);
     if (empty($houseInfo)) {
         return self::buildReturn(0, sprintf('没有获取到房源[%d]信息', $choicePlanInfo['houseId']));
     }
     if ($houseInfo['isDelete'] == Model_House_JpHouseIdx::ENUM_IS_DELETE_YES) {
         return self::buildReturn(0, sprintf('房源[%d]已经删除[%d]', $choicePlanInfo['houseId'], $houseInfo['isDelete']));
     }
     /** 获取房源的板块id */
     if (in_array($houseInfo['houseType'], array(Model_House_JpHouseIdx::ENUM_HOUSE_TYPE_OFFICE_RENT, Model_House_JpHouseIdx::ENUM_HOUSE_TYPE_OFFICE_SALE))) {
         $propertyInfo = Model_House_JpBuilding::getBuildingById($houseInfo['propertyId'], array('blockId'));
     } else {
         $propertyInfo = Model_House_JpProperty::getPropertyById($houseInfo['propertyId'], array('blockId', 'isRoad'));
     }
     $blockId = $propertyInfo['blockId'];
     /** 商铺自选房源精选板块ID从房源信息表里取 */
     if (in_array($houseInfo['houseType'], array(Model_House_JpHouseIdx::ENUM_HOUSE_TYPE_SHOP_RENT, Model_House_JpHouseIdx::ENUM_HOUSE_TYPE_SHOP_SALE)) && $propertyInfo['isRoad'] == 1) {
         $houseTypeClass = Model_House_JpHouseIdx::getHouseTypeModelClass($houseInfo['houseType']);
         $extendHouseInfo = $houseTypeClass::getPropInfoById($houseInfo['id']);
         $blockId = $extendHouseInfo['blockId'];
     }
     /** 获取商圈ID */
     $businessCycleId = Bll_House_JpHouseInfo::getBusinessCycleId($houseInfo['cityId'], $blockId, $houseInfo['houseType']);
     /** 更新计划的板块和商圈ID */
     if (!Model_Plan_Jp::updatePlanBlockIdAndNewBlockIdById($choicePlanInfo['id'], $blockId, $businessCycleId)) {
         return self::buildReturn(0, sprintf('更新计划[%d]的板块[%d -> %d]和商圈[%d -> %d]id失败', $choicePlanInfo['id'], $choicePlanInfo['blockId'], $blockId, $choicePlanInfo['newBlockId'], $businessCycleId));
     }
     if (!Model_Choice_JPBidBucket::getBucketInfo($blockId, $businessCycleId, $choicePlanInfo['houseType'], $choicePlanInfo['priceId'])) {
         Model_Choice_JPBidBucket::initBucketInfo($blockId, $businessCycleId, $choicePlanInfo['houseType'], $choicePlanInfo['priceId'], $choicePlanInfo['cityId']);
     }
     Model_Choice_JPBidBucket::incrementUsedNumEx($blockId, $businessCycleId, $choicePlanInfo['houseType'], $choicePlanInfo['priceId']);
     return self::buildReturn(1, sprintf('更新计划[%d]的板块[%d -> %d]和商圈[%d -> %d]id成功', $choicePlanInfo['id'], $choicePlanInfo['blockId'], $blockId, $choicePlanInfo['newBlockId'], $businessCycleId));
 }
Beispiel #14
0
 /**
  * 判断该task的房子  不在线则通知上
  * @param $task
  * @return bool
  * @throws Exception
  */
 public function dealTask($task)
 {
     $houseInfo = $task;
     $proId = $houseInfo['id'];
     $cityId = $houseInfo['cityId'];
     $brokerInfo = Model_Broker_JpBroker::data_access()->filter('id', $houseInfo['memberId'])->get_row();
     //查询城市配置信息
     $ComboConfig = DAO_My_ComboConfig::getComboConfigByCityId($cityId);
     // 判断solr是否在线  不在线通知上
     if ($ComboConfig && $ComboConfig['type'] == 0) {
         //套餐城市
         if (Bll_Combo_HouseRelation::getOnlineRelationByHouseId($proId, Bll_Combo_HouseRelation::SITE_TYPE_JP)) {
             $result = Bll_Combo_NoticeSolrUpDown::noticeComboSolrJpAPI($cityId, $brokerInfo['ajkMemberId'], $proId, $houseInfo['houseType'], 1);
             $this->setLog(sprintf('房源 %s 通知中间件返回的结果status=%s ; message=%s' . PHP_EOL, $proId, $result['status'], $result['message']));
             $this->setLog(sprintf('房源 %s 在套餐推广中, 需要通知solr上' . PHP_EOL, $proId));
             return true;
         }
         return true;
     } else {
         //ppc城市
         if ($houseInfo['fixSpreadId'] != 0) {
             $spreadInfo = Model_Plan_Jp::data_access()->filter('id', $houseInfo['fixSpreadId'])->filter('type', Model_Plan_Jp::ENUM_TYPE_FIX)->filter('isDelete', Model_Plan_Jp::ENUM_IS_DELETE_NO)->get_row();
             if ($spreadInfo && $spreadInfo['status'] == 2) {
                 // 定价在线 需要通知上
                 $result = Bll_Combo_NoticeSolrUpDown::noticeComboSolrJpAPI($cityId, $brokerInfo['ajkMemberId'], $proId, $houseInfo['houseType'], 1);
                 $this->setLog(sprintf('房源 %s 通知中间件返回的结果status=%s ; message=%s' . PHP_EOL, $proId, $result['status'], $result['message']));
                 $this->setLog(sprintf('房源 %s 在定价推广中, 需要通知solr上' . PHP_EOL, $proId));
                 return true;
             }
         }
         return true;
     }
 }
 public static function updateBucketStatusAndHouseToSolr($spreadInfo, $brokerId = 0, $func = '', $reason = '')
 {
     $bidBucket = Model_Choice_JPBidBucket::getBucketInfo($spreadInfo->blockId, $spreadInfo->newBlockId, $spreadInfo->houseType, $spreadInfo->priceId);
     $limit = $bidBucket['totalNum'];
     $bidChoicePlan = Model_Plan_Jp::getBidChoicePlan($spreadInfo->blockId, $spreadInfo->newBlockId, $spreadInfo->priceId, $spreadInfo->houseType, $limit, $spreadInfo->memberId, $spreadInfo->cityId);
     $upHouse = $downHouse = array();
     if ($bidChoicePlan && $bidBucket) {
         foreach ($bidChoicePlan as $i => $planInfo) {
             if ($i < $bidBucket['maxOnlineNum']) {
                 if (6 == $planInfo->status) {
                     //将计划状态改成 2
                     $planInfo->status = 2;
                     $planInfo->save();
                     $params = array();
                     $params['houseId'] = $planInfo->houseId;
                     $params['plan_id'] = $planInfo->id;
                     $params['ajk_broker_id'] = $brokerId;
                     $params['city_id'] = $spreadInfo->cityId;
                     $params['type'] = 14;
                     //13-精选排队中,14-精选推广,15-取消精选推广,16-取消精选排队
                     $params['changeType'] = self::$propLog[$func]['changeType'];
                     $_remark = '由于' . $reason . ',导致房源:' . $planInfo->houseId . '上架';
                     self::writeHouseLogV2($params, $_remark);
                     //房源上架tosolr
                     Bll_House_JpHouseInfo::updateHouseToSolr(1, $planInfo->houseId, 1);
                     //通知更新q_spread_bid_update表 计算竞价系数
                     Model_Plan_JpSpreadBidUpdate::setBidUpdateQ($planInfo->id);
                     $upHouse[] = $planInfo->houseId;
                 }
             } else {
                 if (2 == $planInfo->status) {
                     //将计划状态改成 6
                     $planInfo->status = 6;
                     $planInfo->save();
                     $params = array();
                     $params['houseId'] = $planInfo->houseId;
                     $params['plan_id'] = $planInfo->id;
                     $params['ajk_broker_id'] = $brokerId;
                     $params['city_id'] = $spreadInfo->cityId;
                     $params['type'] = 15;
                     //13-精选排队中,14-精选推广,15-取消精选推广,16-取消精选排队
                     $params['changeType'] = self::$propLog[$func]['changeType'];
                     $_remark = '由于' . $reason . ',导致房源:' . $planInfo->houseId . '下架';
                     self::writeHouseLogV2($params, $_remark);
                     //房源下架tosolr
                     Bll_House_JpHouseInfo::updateHouseToSolr(1, $planInfo->houseId, 1);
                     //通知更新q_spread_bid_update表 计算竞价系数
                     Model_Plan_JpSpreadBidUpdate::setBidUpdateQ($planInfo->id);
                     $downHouse[] = $planInfo->houseId;
                 }
             }
         }
         $remark = '由于' . $reason . ',导致商业地产精选推广';
         if ($upHouse || $downHouse) {
             if ($upHouse) {
                 $remark .= '上架房源:' . implode(',', $upHouse);
             }
             if ($downHouse) {
                 $remark .= '下架房源:' . implode(',', $downHouse);
             }
         } else {
             $remark .= '暂无上下架房源';
         }
         return $remark;
     }
     return $reason;
 }
Beispiel #16
0
 /**
  * 金铺-精选房源管理页面
  * 返回值 为页面参数,所以必须是数组
  *
  * @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;
 }
 /**
  *
  * 获取经纪人的竞价房源数
  *
  * @param $brokerId
  * @param $cityId
  * @param $siteType
  * @return int
  */
 public static function getBrokerBidNum($brokerId, $cityId, $siteType)
 {
     $num = 0;
     switch ($siteType) {
         case 'ajk':
             $bidList = Model_Plan_EsfAjkPropSpread::getValidPlan($brokerId, $cityId, true);
             foreach ($bidList as $bid) {
                 if ($bid['status'] == 1) {
                     $num += 1;
                 }
             }
             break;
         case 'hz':
             $brokerMapping = Bll_Broker_MainBusiness::getDataByEsfId($brokerId);
             //根据
             $bidList = Model_Plan_HzPlanBasic::get_online_bid_plan_ex($brokerId, 2);
             $num = count($bidList);
             break;
         case 'jp':
             $brokerMapping = Bll_Broker_MainBusiness::getDataByEsfId($brokerId);
             //根据经纪人查询商铺相应
             $bidList = Model_Plan_Jp::getPlanByMemberId($brokerMapping['jpBrokerid'], 2, array(2));
             $num = count($bidList);
             break;
         default:
             break;
     }
     return $num;
 }
 /**
  * 结算成功以后修复精选计划状态
  *
  * @param array $task
  */
 private function repairSpreadPlanState($task)
 {
     printf('修复精选推广计划状态 Task:%s' . PHP_EOL, json_encode($task));
     if ($task['siteType'] == 3) {
         $choicePlanInfo = Model_Plan_Jp::getPlanInfoById($task['planId'], true);
         if (empty($choicePlanInfo)) {
             printf('没有获取到金铺精选计划信息。' . PHP_EOL);
             return;
         }
         printf('金铺精选计划信息: %s' . PHP_EOL, json_encode($choicePlanInfo));
         if ($choicePlanInfo['status'] != Model_Plan_Jp::ENUM_STATUS_HOLD) {
             printf('金铺精选计划不是结算状态[%d],不处理。' . PHP_EOL, $choicePlanInfo['status']);
             return;
         }
         if (Model_Plan_Jp::updateChoiceStateById($task['planId'], Model_Plan_Jp::ENUM_STATUS_OVER)) {
             printf('修复金铺精选推广计划[%d]状态成功。' . PHP_EOL, $task['planId']);
         } else {
             printf('更新金铺精选推广计划[%d]状态失败。' . PHP_EOL, $task['planId']);
         }
         return;
     }
 }
Beispiel #19
0
 public static function edit_prop($params)
 {
     $all_return[] = "队列(" . $params['id'] . ")开始处理";
     $typeFourFlag = false;
     if ($params['pro_id']) {
         //是否套餐经纪人
         //$broker_info = Dao_Broker_BrokerInfo::get_broker_base_info($params['broker_id']);
         if (Bll_City::isComboCity($params['city_id'])) {
             //套餐经纪人 房源在线
             $all_return[] = '套餐经纪人';
             $brokerPropRelation = Model_Combo_HouseRelation::data_access('jp')->filter('brokerId', $params['broker_id'])->filter('houseId', $params['pro_id'])->find_only();
             if ($brokerPropRelation->state >= Model_Combo_HouseRelation::ENUM_HOUSE_ONLINE && $brokerPropRelation->state <= 199) {
                 $all_return[] = '需要写入更新日志';
                 $typeFourFlag = true;
             }
         } else {
             //ppc经纪人 定价推广在线
             $all_return[] = 'PPC经纪人';
             $houseInfoObj = Model_House_JpHouseIdx::getPropInfoByPk($params['pro_id']);
             if ($houseInfoObj->fixSpreadId) {
                 $fixPlanInfoObj = Model_Plan_Jp::getPlanInfoByPk($houseInfoObj->fixSpreadId);
                 if ($fixPlanInfoObj->status == Model_Plan_Jp::ENUM_STATUS_ONLINE) {
                     $all_return[] = '需要写入更新日志';
                     $typeFourFlag = true;
                 }
             }
         }
     }
     if ($typeFourFlag) {
         $data = self::build_prop_log($params, 4, "房源更新", $params['broker_id']);
         if (Model_Log_HouseLogNew::create($data, date('Ymd'))->save()) {
             $all_return[] = '房源更新日志写入成功';
         }
     }
     $data = self::build_prop_log($params, 2, "房源编辑", $params['broker_id']);
     if (Model_Log_HouseLogNew::create($data, date('Ymd'))->save()) {
         $all_return[] = '房源编辑日志写入成功';
         return self::build_return(1, $all_return);
     }
     $all_return[] = '房源编辑日志写入失败';
     return self::build_return(0, $all_return);
 }
Beispiel #20
0
 /**
  * 根据城市ID批量获取有效的计划
  *
  * @param int $cityId
  * @param int $startId
  * @param int $limit
  * @return array
  */
 public static function scanValidaFixPlanByCityId($cityId, $startId, $limit)
 {
     return Model_Plan_Jp::scanValidaFixPlanByCityId($cityId, $startId, $limit);
 }
Beispiel #21
0
 private static function dealBuildingAreaChange($cityId, $oldBlockId, $newBlockId, $houseType, $houseLogType, $actionType)
 {
     $useBusinessCycleConfigOption = array(Model_House_JpHouseIdx::ENUM_HOUSE_TYPE_OFFICE_RENT => 'clues_search_condition_office_rent_list_switch', Model_House_JpHouseIdx::ENUM_HOUSE_TYPE_OFFICE_SALE => 'clues_search_condition_office_sale_list_switch');
     $useBusinessCycleConfig = APF::get_instance()->get_config($useBusinessCycleConfigOption[$houseType], 'jpmulticity');
     $useBusinessCycle = isset($useBusinessCycleConfig[$cityId]) && $useBusinessCycleConfig[$cityId];
     if ($useBusinessCycle) {
         $oldBusinessCycleId = Model_Jinpu_NewBusinessBlockMap::getNewBusinessCycleByOldBlockId($oldBlockId);
         $choicePlanList = Model_Plan_Jp::getValidChoicePlanByBlockIdAndNewBlockId($oldBlockId, $oldBusinessCycleId, $houseType);
     } else {
         $choicePlanList = Model_Plan_Jp::getValidChoicePlanByBlockIdAndNewBlockId($oldBlockId, 0, $houseType);
     }
     $rtn = array();
     foreach ($choicePlanList as $choicePlan) {
         $houseLog = array();
         $houseLog['houseId'] = $choicePlan['houseId'];
         $houseLog['planId'] = $choicePlan['id'];
         $houseLog['brokerId'] = $choicePlan['ajkBrokerId'];
         $houseLog['cityId'] = $choicePlan['cityId'];
         $houseLog['type'] = $houseLogType;
         $houseLog['changeType'] = $actionType;
         $houseLog['remark'] = sprintf('房源所在物业、写字楼板块发生变更[%d -> %d]', $oldBlockId, $newBlockId);
         $houseLog['addDate'] = date('Y-m-d H:i:s');
         $houseLog['operatorId'] = 0;
         $houseLog['siteType'] = 3;
         if (!Model_Log_HouseLogNew::create($houseLog, date('Ymd'))->save()) {
             $rtn[] = sprintf('板块变更房源[%d]日志写入失败', $choicePlan['houseId']);
             continue;
         }
         $rtn[] = sprintf('板块变更房源[%d]日志写入成功', $choicePlan['houseId']);
     }
     return $rtn;
 }
 /**
  * 查询房源的精选(竞价)信息
  *
  * @param $list
  * @return array
  */
 private function getProBidInfo($list)
 {
     static $_cache = array();
     if (isset($_cache[$list['id']])) {
         return $_cache[$list['id']];
     }
     $bidInfo = array();
     //根据房源去查询计划信息
     if ($list['siteType'] == 1) {
         //二手房
         $ajkBidInfo = Model_Plan_AjkPropspread::getAjkPropspreadByProId($list['houseId']);
         if (!empty($ajkBidInfo)) {
             $bidInfo['bidVersion'] = $ajkBidInfo['bidVersion'];
             $bidInfo['bidId'] = $ajkBidInfo['id'];
         }
     } elseif ($list['siteType'] == 2) {
         //租房
         $hzBidId = Model_Plan_HzPlanning::getPropBidPlan($list['houseId']);
         if (!empty($hzBidId)) {
             //查询计划信息
             $hzBidInfo = Model_Plan_HzPlanBasic::get_plan_by_id($hzBidId['plan_id']);
             if (!empty($hzBidInfo) && in_array($hzBidInfo['status'], array(Const_HzPlan::SPREAD, Const_HzPlan::AUTOOVER, Const_HzPlan::MENUOVER, Const_HzPlan::PAUSE, Const_HzPlan::AWAIT, Const_HzPlan::UPPERLIMIT, Const_HzPlan::ENDTIME, Const_HzPlan::WAITING)) || $hzBidInfo['flag'] != 1) {
                 $bidInfo['bidVersion'] = $hzBidInfo['bid_version'];
                 $bidInfo['bidId'] = $hzBidInfo['id'];
             }
         }
     } elseif ($list['siteType'] == 3) {
         //金铺
         $jpBidInfo = Model_Plan_Jp::getBidPlanByHouseIdV2($list['houseId']);
         if (!empty($jpBidInfo)) {
             $bidInfo['bidVersion'] = $jpBidInfo->bidVersion;
             $bidInfo['bidId'] = $jpBidInfo->id;
         }
     }
     $_cache[$list['id']] = $bidInfo;
     return $bidInfo;
 }
 /**
  * @param $planId
  * @param $forceMaster
  * @return array
  */
 public static function getFixPlanInfoById($planId, $forceMaster = false)
 {
     $houseObj = Model_Plan_Jp::data_access()->filter('id', $planId);
     if ($forceMaster) {
         $houseObj->force_master();
     }
     $house = $houseObj->get_row();
     if (empty($house) || empty($house['fixSpreadId'])) {
         return array('success' => false, 'data' => '推广不存在');
     }
     $plan = Model_Plan_Jp::data_access()->filter('id', intval($house['fixSpreadId']))->filter('type', Model_Plan_Jp::ENUM_TYPE_FIX)->filter('isDelete', Model_Plan_Jp::ENUM_IS_DELETE_NO)->get_row();
     if ($plan['memberId'] != $house['memberId']) {
         return array('success' => false, 'data' => '没有权限操作推广');
     }
     return array('success' => true, 'data' => $plan);
 }
Beispiel #24
0
 public static function plan_budget_top($params)
 {
     $all_return = array();
     $all_return[] = "队列(" . $params['id'] . ")开始处理";
     //获取计划信息
     $fixPlanInfoObj = Model_Plan_Jp::getPlanInfoByPk($params['plan_id']);
     if ($fixPlanInfoObj) {
         $all_return[] = "定价计划" . $fixPlanInfoObj->id . ",status=" . $fixPlanInfoObj->status . ",no_budget_date=" . $fixPlanInfoObj->noBudgetDate;
         if (BLL_Fixedspread_StaticPlanUpDownSwicher::isOnline()) {
             //更新计划信息
             $fixPlanInfoObj->noBudgetDate = time();
             $fixPlanInfoObj->save();
             $all_return[] = "更新计划nobudget数据成功";
         }
         if ($params['remark']) {
             $remark = json_decode($params['remark'], true);
             foreach ($remark as $houseId) {
                 $params['pro_id'] = $houseId;
                 $data = Bll_JpPropBll::build_prop_log($params, 7, "房源第二天推广", $params['broker_id']);
                 if (!Model_Log_HouseLogNew::create($data, date('Ymd'))->save()) {
                     $all_return[] = "房源" . $params['pro_id'] . "第二天推广日志写入失败";
                 } else {
                     $all_return[] = "房源" . $params['pro_id'] . "第二天推广日志写入成功";
                 }
             }
         }
     }
     //写限额不足计划日志
     $data = self::build_plan_log($params, 6, "计划限额不足停止", 0);
     Model_House_UpDown_PlanLog::create($data, date('m'))->save();
     $all_return[] = "计划限额不足日志写入成功";
     return Bll_JpPropBll::build_return(1, $all_return);
 }
Beispiel #25
0
 public static function broker_restitution($params)
 {
     $all_return[] = "队列(" . $params['id'] . ")开始处理";
     $all_return[] = '金铺系统返还';
     //todo 查询用户所有定价计划,开启计划,上线房源
     $ajk_broker_id = $params['broker_id'];
     //获取金铺经纪人broker_id
     $jpBrokerInfoObj = Model_Broker_JpBroker::getJpBrokerInfoByAjkBrokerId($params['broker_id']);
     $params['broker_id'] = $jpBrokerInfoObj->id;
     //获取由于余额用完停止的计划
     $fixInfoObjs = Model_Plan_Jp::getNoBalancePlan($params['broker_id']);
     foreach ($fixInfoObjs as $fixInfoObj) {
         $plan_log = array();
         $plan_log['id'] = $params['id'];
         $plan_log['plan_id'] = $fixInfoObj->id;
         $plan_log['broker_id'] = $ajk_broker_id;
         $plan_log['city_id'] = $fixInfoObj->cityId;
         $plan_log['type'] = $params['type'];
         $plan_log = Bll_JpFixPlanBll::build_plan_log($plan_log, 8, "系统返还", 0);
         //写计划日志
         if (!Model_House_UpDown_PlanLog::create($plan_log, date('m'))->save()) {
             $all_return[] = "计划" . $plan_log['planId'] . "房源推广日志写入失败";
         } else {
             $all_return[] = "计划" . $plan_log['planId'] . "房源推广日志写入成功";
         }
         //计划开启
         $fixInfoObj->status = 2;
         $fixInfoObj->stopReason = 0;
         if (!$fixInfoObj->save()) {
             return array('status' => 0, 'msg' => array("定价计划" . $plan_log['planId'] . ",更新失败"));
         }
         //获取房源列表
         $houseInfoObjs = Model_House_JpHouseIdx::getHouseInfoByFixPlanId($plan_log['planId']);
         if ($houseInfoObjs) {
             foreach ($houseInfoObjs as $houseInfoObj) {
                 $prop_log['id'] = $params['id'];
                 $prop_log['pro_id'] = $houseInfoObj->id;
                 $prop_log['plan_id'] = $plan_log['planId'];
                 $prop_log['broker_id'] = $ajk_broker_id;
                 $prop_log['city_id'] = $houseInfoObj->cityId;
                 $prop_log['type'] = $params['type'];
                 $prop_log = Bll_JpPropBll::build_prop_log($prop_log, 5, "系统返还", 0);
                 //写房源日志
                 if (!Model_Log_HouseLogNew::create($prop_log, date('Ymd'))->save()) {
                     $all_return[] = "房源" . $houseInfoObj->id . "系统返还后房源推广日志写入失败";
                 } else {
                     $all_return[] = "房源" . $houseInfoObj->id . "系统返还后房源推广日志写入成功";
                 }
                 //获取房源分表信息
                 $houseClass = Model_House_JpHouseIdx::getHouseTypeModelClass($houseInfoObj->houseType);
                 $houseObj = $houseClass::getPropInfoByPk($houseInfoObj->id);
                 //更新展示房源状态
                 $houseObj->isList = 1;
                 if ($houseObj->save()) {
                     $all_return[] = "houseType=" . $houseInfoObj->houseType . ",更新分表isList=1成功";
                 } else {
                     $all_return[] = "houseType=" . $houseInfoObj->houseType . ",更新分表isList=1失败";
                 }
             }
         }
     }
     return Bll_JpPropBll::build_return(1, $all_return);
 }