예제 #1
0
 /**
  *
  */
 public function handle_request()
 {
     //分表
     $date = date('Ymd');
     //获取游标
     $dateFlag = $this->getFlag();
     if (!empty($dateFlag)) {
         $date = $dateFlag['date'];
     }
     //竞价队列数据获取
     $split = date('m', strtotime($date));
     $year = date('Y', strtotime($date));
     $day = date('d', strtotime($date));
     $BidList = Model_Choice_ActionQueue::getBidQueenList($split);
     //判断当前队列是否处理完成
     if (empty($BidList)) {
         //判断是否切换表
         if ($split + 0 != date('m') + 0) {
             $split += 1;
             if ($split < 10) {
                 $date = $year . '0' . $split . $day;
             } elseif ($split <= 12) {
                 $date = $year . $split . $day;
             } else {
                 $date = $year + 1 . '0' . ($split - 12) . $day;
             }
             //记录表游标
             $this->setFlag(array('date' => $date));
         }
         //休息1秒钟
         $this->setShCommonSleepTime(1);
         $this->setLog(date('Y-m-d H:i:s') . ' 处理完成');
         exit;
     }
     //队列数据处理
     foreach ($BidList as $list) {
         try {
             $AjkChoice = new Bll_Plan_Bid_AjkChoice();
             $AjkBlockChoice = new Bll_Plan_Bid_AjkBlockChoice();
             $result = '';
             if ($list['siteType'] == 1) {
                 //查询计划信息
                 $propSpread = Model_Plan_AjkPropspread::getAjkPropspreadById($list['planId']);
             }
             switch ($list['actionId']) {
                 case 1:
                     //精选推广
                     if ($list['siteType'] == 1) {
                         $list['bidStatus'] = 1;
                         if ($propSpread['model'] == 1) {
                             $result = $AjkChoice->choiceStartForJobByBroker($list);
                         } elseif ($propSpread['model'] == 2) {
                             $result = $AjkBlockChoice->blockChoiceStartForJobByBroker($list);
                         }
                     } elseif ($list['siteType'] == 2) {
                         $result = Bll_Plan_Bid_HzChoice::choiceSpread($list);
                     } elseif ($list['siteType'] == 3) {
                         $result = Bll_Plan_Bid_JpChoice::choicePromotion($list);
                     }
                     break;
                 case 2:
                     //手动停止
                     if ($list['siteType'] == 1) {
                         $list['bidStatus'] = 3;
                         if ($propSpread['model'] == 1) {
                             $result = $AjkChoice->choiceStopForJobByBroker($list);
                         } elseif ($propSpread['model'] == 2) {
                             $result = $AjkBlockChoice->blockChoiceStopForJobByBroker($list);
                         }
                     } elseif ($list['siteType'] == 2) {
                         $result = Bll_Plan_Bid_HzChoice::stopChoiceSpread($list);
                     } elseif ($list['siteType'] == 3) {
                         $result = Bll_Plan_Bid_JpChoice::stopSpread($list);
                     }
                     break;
                 case 3:
                     //计划14天到期
                     if ($list['siteType'] == 1) {
                         $list['bidStatus'] = 6;
                         if ($propSpread['model'] == 1) {
                             $result = $AjkChoice->choiceStopForJobBySystem($list);
                         } elseif ($propSpread['model'] == 2) {
                             $result = $AjkBlockChoice->blockChoiceStopForJobBySystem($list);
                         }
                     } elseif ($list['siteType'] == 2) {
                         $result = Bll_Plan_Bid_HzChoice::timeIsUp($list);
                     } elseif ($list['siteType'] == 3) {
                         $result = Bll_Plan_Bid_JpChoice::expireSpread($list);
                     }
                     break;
                 case 4:
                     //计划没钱
                     if ($list['siteType'] == 1) {
                         $list['bidStatus'] = 5;
                         if ($propSpread['model'] == 1) {
                             $result = $AjkChoice->choiceStopForJobByNoMoney($list);
                         } elseif ($propSpread['model'] == 2) {
                             $result = $AjkBlockChoice->blockChoiceStopForJobByNoMoney($list);
                         }
                     } elseif ($list['siteType'] == 2) {
                         $result = Bll_Plan_Bid_HzChoice::planNoMoney($list);
                     } elseif ($list['siteType'] == 3) {
                         $result = Bll_Plan_Bid_JpChoice::noMoneySpread($list);
                     }
                     break;
                 case 5:
                     //房源移出定价计划,导致精选停止(房源日志发起)
                     if ($list['siteType'] == 1) {
                         $list['bidStatus'] = 2;
                         if ($propSpread['model'] == 1) {
                             $result = $AjkChoice->choiceStopForJobBySystem($list);
                         } elseif ($propSpread['model'] == 2) {
                             $result = $AjkBlockChoice->blockChoiceStopForJobBySystem($list);
                         }
                     } elseif ($list['siteType'] == 2) {
                         $result = Bll_Plan_Bid_HzChoice::removeFixPlanForChoice($list);
                     } elseif ($list['siteType'] == 3) {
                         $result = Bll_Plan_Bid_JpChoice::removeFixSpread($list);
                     }
                     break;
                 case 6:
                     //房源价格变更(房源日志发起)
                     $priceaArr = json_decode($list['createRemark'], true);
                     $list = array_merge($list, $priceaArr);
                     if ($list['siteType'] == 1) {
                         $list['bidStatus'] = 4;
                         if ($propSpread['model'] == 1) {
                             $result = $AjkChoice->choiceChangePriceForJob($list);
                         } elseif ($propSpread['model'] == 2) {
                             $result = $AjkBlockChoice->blockChoiceChangePriceForJob($list);
                         }
                     } elseif ($list['siteType'] == 2) {
                         $result = Bll_Plan_Bid_HzChoice::changeProPrice($list);
                     } elseif ($list['siteType'] == 3) {
                         $result = Bll_Plan_Bid_JpChoice::changePriceForHouse($list);
                     }
                     break;
                 case 7:
                     //房源移出定价计划,导致竞价停止(房源日志发起)20140717 caoyang 新增
                     if ($list['siteType'] == 1) {
                         /** 二手房走老队列 */
                     } elseif ($list['siteType'] == 2) {
                         $result = Bll_Plan_Bid_HzChoice::removeFixPlanForBid($list);
                     } elseif ($list['siteType'] == 3) {
                         $result = Bll_Plan_Bid_JpBidManage::stopJpBidData($list);
                     }
                     break;
                 case Const_ChoiceType::CHOICE_REMOVE_FROM_COMBO:
                     //房源取消套餐推广,导致精选停止(房源日志发起)20140815 caoyang 新增
                     if ($list['siteType'] == 1) {
                         $list['bidStatus'] = 2;
                         if ($propSpread['model'] == 1) {
                             $result = $AjkChoice->choiceStopForJobBySystem($list);
                         } elseif ($propSpread['model'] == 2) {
                             $result = $AjkBlockChoice->blockChoiceStopForJobBySystem($list);
                         }
                     } elseif ($list['siteType'] == 2) {
                         $result = Bll_Plan_Bid_HzChoice::removeComboForChoice($list);
                     } elseif ($list['siteType'] == 3) {
                         $result = Bll_Plan_Bid_JpChoice::removeFixSpread($list);
                     }
                     break;
                 case Const_ChoiceType::BID_REMOVE_FROM_COMBO:
                     //房源取消套餐推广,导致竞价停止(房源日志发起)20140815 caoyang 新增
                     if ($list['siteType'] == 1) {
                         /** 二手房走老队列 */
                     } elseif ($list['siteType'] == 2) {
                         $result = Bll_Plan_Bid_HzChoice::removeFixPlanForBid($list);
                     } elseif ($list['siteType'] == 3) {
                         $result = Bll_Plan_Bid_JpBidManage::stopJpBidData($list);
                     }
                     break;
                     /** 精选房源板块变更 */
                 /** 精选房源板块变更 */
                 case Const_ChoiceType::CHOICE_HOUSE_AREA_CHANGE:
                     if ($list['siteType'] == 1) {
                         if ($propSpread['model'] == 1) {
                             $result = $AjkChoice->communityMerge($list);
                         } elseif ($propSpread['model'] == 2) {
                             $result = $AjkBlockChoice->communityMerge($list);
                         }
                         break;
                     }
                     if ($list['siteType'] == 2) {
                         $result = Bll_Plan_Bid_HzChoice::houseAreaChange($list);
                         break;
                     } else {
                         if ($list['siteType'] == 3) {
                             $result = Bll_Plan_Bid_JpChoice::houseBlockChange($list);
                         }
                     }
                     break;
                     /** 精选房源价格段变更 */
                 /** 精选房源价格段变更 */
                 case Const_ChoiceType::CHOICE_PRICE_INTERVAL_CHANGE:
                     $result = array('status' => 2, 'msg' => '未知的动作类型');
                     if ($list['siteType'] == 1) {
                         if ($propSpread['model'] == 1) {
                             $result = $AjkChoice->choicePriceIntervalChange($list);
                         } elseif ($propSpread['model'] == 2) {
                             $result = $AjkBlockChoice->choicePriceIntervalChange($list);
                         }
                     }
                     break;
                     /** 精选上下架状态维护,该上没上,改下没下 */
                 /** 精选上下架状态维护,该上没上,改下没下 */
                 case Const_ChoiceType::NOTIFY_SOLR_UP_DOWN:
                     switch ($list['siteType']) {
                         case Const_Site::ANJUKE:
                             $result = $AjkChoice->notifySolrUpDown($list);
                             break;
                         case Const_Site::HAOZU:
                             $result = Bll_Plan_Bid_HzChoice::notifySolrUpDown($list);
                             break;
                         case Const_Site::JINPU:
                             $result = Bll_Plan_Bid_JpChoice::notifySolrUpDown($list);
                             break;
                     }
                     break;
                 default:
                     $result = array('status' => 2, 'msg' => '未知的动作类型');
                     break;
             }
             //解析返回值
             if ($list['siteType'] == 1) {
                 $status = $result ? 1 : 2;
                 if ($propSpread['model'] == 1) {
                     $updateRemark = $AjkChoice->getMsg();
                 } elseif ($propSpread['model'] == 2) {
                     $updateRemark = $AjkBlockChoice->getMsg();
                 }
             } elseif ($list['siteType'] == 2) {
                 $status = $result['status'] ? 1 : 2;
                 $updateRemark = is_array($result['msg']) ? implode(';', $result['msg']) : $result['msg'];
             } elseif ($list['siteType'] == 3) {
                 $status = $result['status'] ? 1 : 2;
                 $updateRemark = is_array($result['msg']) ? implode(';', $result['msg']) : $result['msg'];
             } else {
                 $status = 2;
                 $updateRemark = '未知的网站类型';
             }
         } catch (Exception $e) {
             $status = 2;
             $updateRemark = print_r($e, true);
         }
         //更新队列状态
         Model_Choice_ActionQueue::setBidQueenStatusById($split, $list['id'], $status, $updateRemark);
         //记录处理日志
         $this->setLog(date('Y-m-d H:i:s') . ' id:' . $list['id'] . '; 网站: ' . $list['siteType'] . '; split:' . $split . '; remark:' . $updateRemark);
         //记录表游标
         $this->setFlag(array('date' => $date));
     }
     //休息10毫秒
     $this->setShCommonSleepTime(0.01);
 }
예제 #2
0
 /**
  * @param $spreaId
  * @param $oldPrice
  * @param $newPrice
  *
  */
 public function choiceChangePriceForJob($qInfo)
 {
     $this->qInfo = $qInfo;
     //查询计划信息
     //        $ajkPropSpread = Model_Plan_AjkPropspread::getAjkPropspreadByProId($proId);
     $ajkPropSpread = Model_Plan_AjkPropspread::getAjkPropspreadById($qInfo['planId']);
     if (empty($ajkPropSpread)) {
         $this->setMsg('未知的精选计划');
         return false;
     }
     //判断计划状态
     if (!in_array($ajkPropSpread['status'], array(1, 11))) {
         $this->setMsg('非推广或排队中的计划,staus:' . $ajkPropSpread['status']);
         return false;
     }
     //获取老的价格段id
     $oldPriceInfo = Model_House_EsfPrice::get_price($ajkPropSpread['cityId'], $qInfo['oldPrice']);
     if (empty($oldPriceInfo)) {
         $this->setMsg('未知的价格段;cityId:' . $ajkPropSpread['cityId'] . ';oldPrice:' . $qInfo['oldPrice']);
         return false;
     }
     //获取新的价格段id
     $newPriceInfo = Model_House_EsfPrice::get_price($ajkPropSpread['cityId'], $qInfo['newPrice']);
     if (empty($newPriceInfo)) {
         $this->setMsg('未知的价格段;cityId:' . $ajkPropSpread['cityId'] . ';newPrice:' . $qInfo['newPrice']);
         return false;
     }
     //比较新老价格段
     if ($oldPriceInfo['id'] == $newPriceInfo['id']) {
         $this->setMsg('新老价格段一样,oldPriceId:' . $oldPriceInfo['id'] . ',newPriceId:' . $newPriceInfo['id']);
         return true;
     }
     //更新计划状态
     if (0 == Model_Plan_AjkPropspread::setAjkPropspreadById($ajkPropSpread['id'], $qInfo['bidStatus'])) {
         $this->setMsg(sprintf('更新计划[%d]状态失败 status=%d, newStatus=%d', $ajkPropSpread['id'], $ajkPropSpread['status'], $qInfo['bidStatus']));
         return false;
     }
     $this->setMsg('更新计划' . $ajkPropSpread['id'] . '状态为' . $qInfo['bidStatus']);
     //结算
     $this->choiceSettlement($ajkPropSpread['id'], $ajkPropSpread['cityId']);
     //通知solr队列
     $this->choiceUpDownSendSolr(array('city_id' => $ajkPropSpread['cityId'], 'broker_id' => $ajkPropSpread['brokerId'], 'pro_id' => $ajkPropSpread['propId'], 'flag' => 2, 'hpratio' => $ajkPropSpread['offer'], 'comms_hpratio_a' => $ajkPropSpread['commsHpratioA'], 'comms_hpratio' => $ajkPropSpread['commsHpratio'], 'hpstarttime' => $ajkPropSpread['spreadstartdate'], 'hpendtime' => $ajkPropSpread['spreadenddate'], 'hpplanid' => $ajkPropSpread['id'], 'update_time' => time(), 'from_type' => 153));
     //记录房源日志
     Model_Log_HouseLogNew::create(array('houseId' => $ajkPropSpread['propId'], 'planId' => $ajkPropSpread['id'], 'brokerId' => $ajkPropSpread['brokerId'], 'cityId' => $ajkPropSpread['cityId'], 'type' => $ajkPropSpread['status'] == 1 ? 15 : 16, 'changeType' => '40' . $this->qInfo['actionId'], 'remark' => '计划' . $ajkPropSpread['id'] . $this->actionStr[$this->qInfo['actionId']] . ';取消精选推广或排队', 'operatorId' => $this->qInfo['operationId'], 'siteType' => 1), date('Ymd'))->save();
     //计算排名
     return $this->choiceComputeRank($ajkPropSpread, 1);
 }