/** * 房源第一次推广日志生成, ppc_db.ppc_prop_first_spread * * <ol> * <li> * 当房源日志type为房源推广(5)时,才进行下面处理 * </li> * <li> * 如果在ppc_db.ppc_prop_first_spread中存在,不处理 * </li> * <li> * 如果在ppc_db.ppc_prop_first_spread中不存在,插入该表中一条新记录 * </li> * </ol> * * @param $records 定价上下架房源日志数据 */ public function proFirstSpreadLogCreate($record) { if ($record['type'] != 5 && $record['type'] != 20) { //记录处理日志 $this->setLog('不需生成第一次推广日志 ' . __METHOD__); return true; } $propFirstSpreadType = $record['type'] == 5 ? 1 : 3; $result = Model_House_PpcPropFirstSpread::data_access()->filter('type', $propFirstSpreadType)->filter('tradeType', 1)->filter('proId', $record['houseId'])->find_only(); if (!empty($result)) { $this->setLog('已存在第一次推广日志'); return true; } $dataObject = new Model_House_PpcPropFirstSpread(); $dataObject->proId = $record['houseId']; $dataObject->type = $propFirstSpreadType; $dataObject->tradeType = 1; $dataObject->addTime = time(); $dataObject->brokerId = $record['brokerId']; $dataObject->dayDate = date('Ymd', strtotime($record['addDate'])); try { $result = $dataObject->save(); } catch (Exception $e) { $result = false; } if (!$result) { //记录处理日志 $this->setLog('第一次推广日志生成失败'); } else { $this->setLog('第一次推广日志生成成功'); } return true; }
/** * 判断房源是否需要上架 * * @param int $houseId * @param int $cityId * @param int $communityId * @param int $price * @param int $smallPrice * @param int $bigPrice * @return bool */ private function checkUpDown($houseId, $cityId, $communityId, $price, $smallPrice, $bigPrice) { //查询价格段id $priceInfo = Model_House_EsfPrice::get_price($cityId, $price); if (empty($priceInfo)) { $this->setMsg(sprintf('未知的价格段;cityId:%d;proPriceInt:%d', $cityId, $price)); return false; } $priceId = $priceInfo['id']; //获取坑位表信息 $BucketInfo = Model_Choice_EsfBidBucket::get_bucket_info($communityId, $priceId); if (empty($BucketInfo)) { $this->setMsg(sprintf('未知的坑位表[community:%d, priceId:%d]信息;', $communityId, $priceId)); return false; } //根据小区id,价格段获取 $choicePlanList = Model_Plan_AjkPropspread::getAjkPropspreadByBucket($communityId, $smallPrice, $bigPrice, 2); if (empty($choicePlanList)) { $this->setMsg(sprintf('未获取到同小区、价格段的房源。commId:%d;smallPrice:%d;bigPrice:%d', $communityId, $smallPrice, $bigPrice)); return true; } foreach ($choicePlanList as $index => $choicePlan) { if ($choicePlan['propId'] == $houseId && $choicePlan['status'] == 11) { /** 更新排队中的数据位推广中 */ if ($index < $BucketInfo['maxOnlineNum']) { Model_Plan_AjkPropspread::setAjkPropspreadById($choicePlan['id'], 1); //记录竞价第一次推广的日志 $firstSpreadLogs = Model_House_PpcPropFirstSpread::getFirstSpreadLogByHouseId($houseId, Model_House_PpcPropFirstSpread::PROP_FIRST_SPREAD_TYPE_CHOICE); if (empty($firstSpreadLogs)) { $firstSpreadLog = array('proId' => $houseId, 'type' => Model_House_PpcPropFirstSpread::PROP_FIRST_SPREAD_TYPE_CHOICE, 'tradeType' => 1, 'addTime' => time(), 'dayDate' => date('Ymd'), 'brokerId' => $choicePlan['brokerId']); if (1 != Model_House_PpcPropFirstSpread::create($firstSpreadLog)->save()) { $this->setMsg(sprintf('房源[%d]写入第一次推广日志失败', $houseId)); } } //通知solr队列 $this->choiceUpDownSendSolr(array('city_id' => $choicePlan['cityId'], 'broker_id' => $choicePlan['brokerId'], 'pro_id' => $choicePlan['propId'], 'flag' => 1, 'hpratio' => $choicePlan['offer'], 'comms_hpratio_a' => $choicePlan['commsHpratioA'], 'comms_hpratio' => $choicePlan['commsHpratio'], 'hpstarttime' => $choicePlan['spreadstartdate'], 'hpendtime' => $choicePlan['spreadenddate'], 'hpplanid' => $choicePlan['id'], 'update_time' => time(), 'from_type' => 151)); //记录房源日志 Model_Log_HouseLogNew::create(array('houseId' => $choicePlan['propId'], 'planId' => $choicePlan['id'], 'brokerId' => $choicePlan['brokerId'], 'cityId' => $choicePlan['cityId'], 'type' => 14, 'changeType' => '40' . $this->qInfo['actionId'], 'remark' => '计划' . $choicePlan['id'] . $this->actionStr[$this->qInfo['actionId']] . ';重新计算价格段内排名,精选推广', 'operatorId' => $this->qInfo['operationId'], 'siteType' => 1), date('Ymd'))->save(); $this->setMsg(sprintf('planId:%d变更为推广', $choicePlan['id'])); } break; } } return true; }
/** * 获取job数据 * @return array */ protected function getJobData() { return Model_House_PpcPropFirstSpread::getMoreThanId($this->id, $this->limit); }
/** * 房源第一次推广日志生成, ppc_db.ppc_prop_first_spread * * <ol> * <li> * 当房源日志type为房源推广(5)时,才进行下面处理 * </li> * <li> * 如果在ppc_db.ppc_prop_first_spread中存在,不处理 * </li> * <li> * 如果在ppc_db.ppc_prop_first_spread中不存在,插入该表中一条新记录 * </li> * </ol> * * @param $records 定价上下架房源日志数据 */ public function proFirstSpreadLogCreate($records) { foreach ($records as $row) { if ($row->type = 5) { $result = Model_House_PpcPropFirstSpread::data_access()->filter_by_op('type', '=', 1)->filter_by_op('tradetype', '=', 1)->filter_by_op('proId', '=', $row->houseId); if (empty($result)) { $dataObject = new Model_House_PpcPropFirstSpread(); $dataObject->proId = $row->houseId; $dataObject->type = 1; $dataObject->tradeType = 1; $dataObject->addTime = time(); $dataObject->brokerId = $row->brokerId; $dataObject->dayDate = date('Ymd', strtotime($row->addDate)); if (!$dataObject->save()) { if (!$dataObject->save()) { $this->addLogger('队列id' . $row->id . "房源" . $row->houseId . "第一次推广日志生成失败"); } else { $this->addLogger('队列id' . $row->id . "房源" . $row->houseId . "第一次推广日志生成成功"); } } else { $this->addLogger('队列id' . $row->id . "房源" . $row->houseId . "第一次推广日志生成成功"); } } else { $this->addLogger('队列id' . $row->id . "房源" . $row->houseId . "已存在第一次推广日志"); } unset($result); unset($dataObject); } else { $this->addLogger('队列id' . $row->id . "房源" . $row->houseId . "并非推广日志"); } } }