Пример #1
0
 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);
 }