public static function choicePromotion($params = array()) { if (!self::checkJpParams($params)) { return self::buildReturn(0, self::$msg); } $spreadInfo = self::$spreadInfo; $brokerId = self::$brokerId; $spreadId = self::$spreadId; $houseInfo = self::$houseInfo; //新发和重推触发计费 Bll_Log_JpClick::getInstance()->openActiviteBidPayLog($spreadInfo->memberId, $spreadInfo->id); //触发报表统计 Bll_House_JpBwAnalysis::getInstance()->openSaveBluewhaleHouse($spreadInfo->houseId, date('Y-m-d'), $spreadInfo->id, Model_Plan_Jp::ENUM_TYPE_HP); //加入按时间停止计划队列 Model_Plan_JpStop::addSpreadStopQueen($spreadInfo->id, $spreadInfo->endTime); //写给BI看的日志 Bll_Log_JpHouse::getInstance()->writeHouseLog($spreadInfo->houseId, $spreadInfo->id, 1, $spreadInfo->memberId, Model_Log_JpHouseUpDown::ENUM_BID_MEMBER_NEW); ////log 4 张计划log表 Bll_Log_JpPlan::getInstance()->writeSpreadBudgetLog(true, 1, 0, $spreadInfo->id, $spreadInfo->budget); Bll_Log_JpPlan::getInstance()->writeSpreadOfferLog($spreadInfo->id, $houseInfo['info']->spreadOffer, 1, 0); //新增和重推时 Bll_Log_JpPlan::getInstance()->writeSpreadStatusLog(Model_Log_JpSpreadStatusUpdate::ENUM_STATUS_SPREAD_ONLINE, $spreadInfo->id); Bll_Log_JpPlan::getInstance()->writeSpreadHouseLog(true, $spreadInfo->houseId, $spreadInfo->id, Model_Log_JpSpreadHouseUpdate::ENUM_STATUS_HOUSE_IN); $reason = '计划:' . $spreadId; $res = self::updateBucketStatusAndHouseToSolr($spreadInfo, $brokerId, __FUNCTION__, $reason); return self::buildReturn(1, $res); }
public static function getInstance() { if (self::$instance === null) { self::$instance = new self(); } return self::$instance; }
/** * 房源推广变更日志生成 ppc_db.Hz_Pro_Change_Log_ * * <ol> * <li> * 当房源日志type为房源推广(5)时,对应推广变更日志action=1 * </li> * <li> * 当房源日志type为取消推广(6)时,对应推广变更日志action=2 * </li> * <li> * 当房源日志type为取消推广(14)时,对应精选推广变更日志action=1 * </li> * <li> * 当房源日志type为取消推广(15)时,对应精选推广变更日志action=2 * </li> * <li> * 其他不处理 * </li> * </ol> * * @param array $record 定价上下架房源日志数据(金铺篇) */ public function proSpreadChangeLogCreateJp($record) { if ($record['siteType'] != 3) { //记录处理日志 $this->setLog('改网站类型的数据暂不处理(定价推广变更日志)'); return true; } $type = $record['type']; $date = date('Ymd', strtotime($record['addDate'])); if ($type == 5) { $action = 1; $type = 1; } elseif ($type == 6) { $action = 2; $type = 1; } elseif ($type == 14) { $action = 1; $type = 2; } elseif ($type == 15) { $action = 2; $type = 2; } elseif ($type == 21) { $type = 3; $action = 2; } elseif ($type == 20) { $type = 3; $action = 1; } else { //记录处理日志 $this->setLog('不需要生成推广变更日志'); return true; } $dataObject = new Model_House_JpProChangeLog($date); //查询最近的日志 $ChangeLogInfo = $dataObject->getChangeLogByProId($record['houseId'], $date, $type); $Time = 0; //展示时间 if (!empty($ChangeLogInfo)) { switch ($ChangeLogInfo['action']) { case 1: //上一条为推广 if ($action == 1) { //本次为推广 $Time = $ChangeLogInfo['time']; } if ($action == 2) { //本次为取消推广 $Time = $ChangeLogInfo['time'] + time() - strtotime($ChangeLogInfo['logTime']); } break; case 2: //上一条为取消推广 if ($action == 1) { //本次为推广 if (empty($ChangeLogInfo['time'])) { //上一条取消推广时间为0 $Time = strtotime($ChangeLogInfo['logTime']) - strtotime(substr($ChangeLogInfo['logTime'], 0, 10)); } else { $Time = $ChangeLogInfo['time']; } } if ($action == 2) { //本次为取消推广 $Time = $ChangeLogInfo['time']; } break; default: } } $dataObject->propId = $record['houseId']; $dataObject->brokerId = $record['brokerId']; $dataObject->time = $Time; $dataObject->action = $action; $dataObject->type = $type; $dataObject->logTime = date('Y-m-d H:i:s'); $dataObject->actionId = 0; //触发动作id $dataObject->spreadId = $record['planId'] ? $record['planId'] : 0; //计划id if (!$dataObject->save()) { //记录处理日志 $this->setLog('推广变更日志生成失败'); } else { $this->setLog('推广变更日志生成成功'); } //ppc城市定价推广 竞价推广 统计数据进入jp_bluewhale_house //type 1定价 2竞价 3套餐 //action 1 上 2 下 //套餐类型 计划ID=0 Bll_House_JpBwAnalysis::getInstance()->openSaveBluewhaleHouse($record['houseId'], date('Y-m-d'), intval($record['planId']), $type); return true; }
/** * 把房源从竞价推广中移除 * @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' => '操作成功'); } }