public function handle_request_internal() { $cityId = $this->_params['cityId']; $price = $this->_params['price']; $areaId = $this->_params['areaid'] ? $this->_params['areaid'] : 0; $coomId = $this->_params['coomId'] ? $this->_params['coomId'] : 0; $bll = new Bll_Fixedspread_AjkFixedSpread(); $result = $bll->getPriceInterval($cityId, $price, $areaId, $coomId); if ($result['price']) { $ret = array('status' => 'ok', 'data' => array('price' => $result['price'])); } else { $ret = Util_MobileAPI::error(Const_APIStatus::E_PROP_PRICE_ERR); } return $ret; }
/** * 由于套餐变更 下掉多余房子 * @param $brokerId * @param $shouldNum * @return bool */ public static function deleteExtraHouse($brokerId, $shouldNum) { $allReturn = array(); // 获取有效计划 if (!($plans = Dao_Broker_AjkPlan::get_broker_plans($brokerId))) { return Util_GlobalFunc::buildReturn(0, "二手房-该经纪人:{$brokerId}没有有效定价"); } $planIds = array(); foreach ($plans as $plan) { $planIds[] = $plan['id']; } $cityId = $plans[0]['cityId']; // 获取有效计划下有效关系 if (!($plannings = Bll_Fixedspread_AjkFixedSpread::getRelationListByPlanId($planIds, $cityId))) { return Util_GlobalFunc::buildReturn(0, "二手房-该经纪人:{$brokerId}没有有效推广关系"); } $num = count($plannings); //推广房源数 $onlineProIds = array(); foreach ($plannings as $planning) { $onlineProIds[$planning->proId] = $planning; } if ($num > $shouldNum) { // 应该下掉多余房子 $offNum = $num - $shouldNum; $props = Bll_House_Property::getPropertyByBrokerId($brokerId, $cityId); if (!$props) { return Util_GlobalFunc::buildReturn(0, "二手房-该经纪人:{$brokerId}没有房源信息"); } $offProIds = array(); foreach ($props as $prop) { if (isset($onlineProIds[$prop['ProId']])) { $offProIds[] = $prop['ProId']; if (count($offProIds) == $offNum) { break; } } } // 开始下房子操作 if (count($offProIds) > 0) { foreach ($offProIds as $offProId) { $item = $onlineProIds[$offProId]; $result = Bll_Fixedspread_AjkFixedSpread::delPlanPro($item->planId, $item->proId, $cityId); // 出错了 if (is_string($result)) { // $allReturn $allReturn[] = '[' . date('Y-m-d H:i:s') . '] planId: ' . $item->planId . ', proId: ' . $item->proId . ', result: ' . $result; } else { $allReturn[] = '[' . date('Y-m-d H:i:s') . '] planId: ' . $item->planId . ', proId: ' . $item->proId . ', result: ok'; } } } return Util_GlobalFunc::buildReturn(1, $allReturn); } }
public function handle_request_internal() { $brokerId = $this->_params['brokerId']; $plans = Model_Plan_EsfFixedPlan::getValidPlan($brokerId); $props = 0; $result['status'] = 'ok'; if (!empty($plans)) { $planId = $plans['id']; $cityId = $plans['cityid'] ?: 0; $relations = Model_Plan_AjkFixRelation::getRelationListByPlanId($planId, $cityId); if (!empty($relations)) { $propIds = array(); foreach ($relations as $row) { $propIds[] = $row['proId']; } $houseInfo = Bll_House_EsfHouse::getHouseBaseInfo($propIds, $cityId); $props = count($houseInfo); } $planBll = new DAO_My_Ppc_PlanOpe(); $clicks = $planBll->planTodayNewCost($planId); $data['planId'] = $planId; $data['todayClicks'] = $clicks['allclick']; $data['todayConsume'] = Util_Formatter::formatTodayConsume($clicks['allamount']); $data['todayConsumeUnit'] = '元'; $data['totalProps'] = $props; //获取计划状态 $api_url = '/service-ppc/rest/ppc/getPpcPlan/' . $planId . '?resType=1'; $plan_info = Util_CallAPI::get_data_from_java_api($api_url); $data['planStatus'] = $plan_info['data']['plan']['statusDescrip'] == '推广中' ? 1 : 0; $limitInfo = Bll_Fixedspread_AjkFixedSpread::getLimitInfo($brokerId); $data['budget'] = !empty($limitInfo) ? round($limitInfo['amountLimit'] / 100, 2) : 0; $data['budgetUnit'] = '元'; } else { $brokerInfo = Model_Broker_AjkBrokerExtend::getDataByBrokerId($brokerId); $planId = Model_Plan_EsfFixedPlan::addPlan('定价推广组', 1, $brokerInfo->cityId, $brokerInfo->userId, $brokerInfo->brokerId); $data['planId'] = $planId; $data['todayClicks'] = $data['todayConsume'] = $data['totalProps'] = $data['planStatus'] = 0; $data['todayConsumeUnit'] = $data['budgetUnit'] = '元'; $limitInfo = Bll_Fixedspread_AjkFixedSpread::getLimitInfo($brokerId); $data['budget'] = !empty($limitInfo) ? round($limitInfo['amountLimit'] / 100, 2) : 0; } $result['data'] = $data; return $result; }
/** * 判断给定房源是否在线上推广 * @param $brokerId 二手房经纪人ID * @param $cityId 城市ID * @param $type 类型,二手房或者租房或者商业地产 * @param $filterProIds * @param array $updateTimeArr * @param array $newFixedProInfos * @return array */ public function filterProIds($brokerId, $cityId, $type, $filterProIds, &$updateTimeArr = array(), &$newFixedProInfos = array()) { //判断是否是套餐城市 $isCombo = Bll_Combo_HouseRelation::isComboCity($cityId); if ($type == Const_ShowcaseOrders::SALE_DB) { //二手房 //经纪人计划信息 if ($isCombo['data']) { //套餐城市 $comboList = Bll_Combo_HouseRelation::getHouseRelations($brokerId, Bll_Combo_HouseRelation::SITE_TYPE_AJK, 1); foreach ($comboList as $comboVal) { $uTime = strtotime($comboVal['updateTime']); $newFixedProInfos[$comboVal['houseId']] = array($comboVal['houseId'], $uTime); $updateTimeArr[$comboVal['houseId']] = $uTime; } } else { //PPC城市 $brokerPlanInfo = BLL_Plan_EsfPropFixedPlanRelation::get_instance()->getBrokerEsfOnlinePlan($brokerId); if (empty($brokerPlanInfo)) { return array(); } //计划ID $planIds = array(); foreach ($brokerPlanInfo as $brokerPlanVal) { $planIds[] = $brokerPlanVal->id; } //定价推广房源 $fixedProInfos = Bll_Fixedspread_AjkFixedSpread::getFixedOnlineProByPlanIds($cityId, $planIds); if (empty($fixedProInfos)) { return array(); } foreach ($fixedProInfos as $fixedProVal) { $uTime = strtotime($fixedProVal->updatedDateTime); $newFixedProInfos[$fixedProVal->proId] = array($fixedProVal->proId, $uTime); $updateTimeArr[$fixedProVal->proId] = $uTime; } } } elseif ($type == Const_ShowcaseOrders::RENT_DB) { //如果是租房 if ($isCombo['data']) { //套餐城市 $comboList = Bll_Combo_HouseRelation::getHouseRelations($brokerId, Bll_Combo_HouseRelation::SITE_TYPE_HZ, 1); foreach ($comboList as $comboVal) { $uTime = strtotime($comboVal['updateTime']); $newFixedProInfos[$comboVal['houseId']] = array($comboVal['houseId'], $uTime); $updateTimeArr[$comboVal['houseId']] = $uTime; } } else { //PPC城市 $hzBrokerId = intval(Bll_Broker_BrokerCheckInfo::getHzBrokerIdByAjkBrokerId($brokerId)); //定价房源信息 $fixedProInfos = Bll_House_FixedPro::getInstance()->getBrokerHzFiexdProInfo($hzBrokerId); if (empty($fixedProInfos)) { return array(); } foreach ($fixedProInfos as $fixedProVal) { $newFixedProInfos[$fixedProVal->proid] = array($fixedProVal->proid, $fixedProVal->created); $updateTimeArr[$fixedProVal->proid] = $fixedProVal->created; } } } //判断需要过滤的房源ID是否在推广房源信息中 if (!empty($filterProIds)) { foreach ($filterProIds as $filterProKey => $filterProId) { if (empty($newFixedProInfos[$filterProId])) { //不在在线推广房源中,则释放 unset($filterProIds[$filterProKey]); } else { //过滤ID,因为补充逻辑肯定是补充不在过滤ID中的房源 unset($newFixedProInfos[$filterProId]); unset($updateTimeArr[$filterProId]); } } } return $filterProIds; }
/** * 110 房源图片信息变更 * * <ol> * <li> * 查询房源信息是否存在<br> * 如果不存在,返回结束<br> * 如果有效,记录房源编辑日志<br> * </li> * * <li> * 查询房源计划关系<br> * 如果不存在,返回结束<br> * 如果存在,continue<br> * </li> * * <li> * 查询计划信息<br> * 如果计划不在推广,返回结束<br> * 如果计划正在推广或者第二天推广, 房源更新日志<br> * </li> * </ol> */ public static function change_prop_pic($params) { $returnLog = array(); array_push($returnLog, "队列(" . json_encode($params['id']) . ")开始处理"); if (empty($params['pro_id'])) { array_push($returnLog, "房源ID为空"); return self::build_return(1, $returnLog); } if (empty($params['city_id'])) { array_push($returnLog, "城市ID为空"); return self::build_return(1, $returnLog); } //获取房源信息 $propBll = new BLL_Property_Property(); $propInfo = $propBll->getPropBaseInfoById($params['pro_id']); if (isset($propInfo[-9999])) { array_push($returnLog, "获取数据库中房源信息失败"); return self::build_return(0, $returnLog); } if (empty($propInfo)) { array_push($returnLog, "房源信息为空"); return self::build_return(1, $returnLog); } //房源信息存在写入房源编辑信息 $data = self::build_prop_log($params, 2, "房源编辑" . ";队列表id为" . $params['id'], $params['broker_id']); if (!Model_Log_HouseLogNew::create($data, date('Ymd'))->save()) { array_push($returnLog, "房源编辑日志写入失败"); return self::build_return(0, $returnLog); } array_push($returnLog, "房源编辑日志写入"); //查询房源计划关系 $relationBll = new Bll_FixedSpread_PropFixedPlanRelation(); $relationInfo = $relationBll->getProSpreadRelationByProId($params['pro_id'], $params['city_id']); if (empty($relationInfo)) { array_push($returnLog, "房源计划关系为空"); return self::build_return(1, $returnLog); } /** * 修正房源的计划id */ if (empty($params['plan_id'])) { $params['plan_id'] = $relationInfo['PlanId']; } //获取计划信息 $planBll = new Bll_Fixedspread_AjkFixedSpread(); $planInfo = $planBll->getStaticPlanById($params['plan_id']); if (empty($planInfo)) { array_push($returnLog, "计划信息为空"); return self::build_return(1, $returnLog); } $planStatus = $planBll->getFixedPlanStatus($planInfo['Status'], $planInfo['ViewTime']); //1. 刪除 2.推广中 3.第二天推广 4.账户没钱停止 5.手动停止 switch ($planStatus) { case 1: array_push($returnLog, "计划状态已被置为删除"); break; case 2: case 3: //房源更新日志 $data = self::build_prop_log($params, 4, "房源更新" . ";队列表id为" . $params['id'], $params['broker_id']); if (!Model_Log_HouseLogNew::create($data, date('Ymd'))->save()) { array_push($returnLog, "房源更新日志写入失败"); return self::build_return(0, $returnLog); } array_push($returnLog, "房源更新日志写入"); break; case 4: array_push($returnLog, "计划状态为账户没钱停止"); break; case 5: array_push($returnLog, "计划状态为手动停止"); break; default: break; } return self::build_return(1, $returnLog); }
/** * 获取二手房房源数据 * [getBrokerEsfPro description] */ private function getBrokerEsfPro() { //判断是否是套餐城市 $data = $proClickInfo = array(); $isCombo = Bll_Combo_HouseRelation::isComboCity($this->cityId); if ($isCombo['data']) { //套餐城市 $comboList = Bll_Combo_HouseRelation::getHouseRelations($this->brokerId, Bll_Combo_HouseRelation::SITE_TYPE_AJK, 1); $proIds = $this->getObjFieldInfo($comboList, 'houseId'); $clicksInfo = Bll_Ppc_NewPackageStatsBrokerDay::getHouseComboClickInfo($proIds, date('Ymd'), Model_Ppc_NewPackageStatsHouseDay::SITE_TYPE_AJK); if (!empty($clicksInfo)) { foreach ($clicksInfo as $val) { if (isset($proClickInfo[$val['propId']])) { $proClickInfo[$val['propId']] += intval($val['cnum']); } else { $proClickInfo[$val['propId']] = intval($val['cnum']); } } } } else { //经纪人计划信息 $brokerPlanInfo = BLL_Plan_EsfPropFixedPlanRelation::get_instance()->getBrokerEsfOnlinePlan($this->brokerId); if (empty($brokerPlanInfo)) { //计划数据为空 $this->outData($data, 1); } //计划IDs $planIds = $this->getObjFieldInfo($brokerPlanInfo, 'id'); //定价推广房源 $fixedProInfos = Bll_Fixedspread_AjkFixedSpread::getFixedOnlineProByPlanIds($this->cityId, $planIds); if (empty($fixedProInfos)) { $this->outData($data, 1); } //房源IDs $proIds = $this->getObjFieldInfo($fixedProInfos, 'proId'); //房源点击量 $proClickDao = new DAO_My_Ppc_PlanOpe(); $proClickInfo = $proClickDao->getProClick($proIds); } $proInfos = Bll_House_EsfHouse::getHouseInfo($proIds, $this->cityId); if (empty($proInfos)) { $this->outData($data, 1); } //经纪人橱窗房源设置信息 $adProInfos = Bll_Broker_ShowcaseAdSetPro::getInstance()->getBrokerAdSalePropInfo($this->brokerId); $addPro = array(); if (!empty($adProInfos)) { foreach ($adProInfos as $adProVal) { $addPro[$adProVal->propId] = true; } } $this->initEsfProData($proInfos, $proClickInfo, $addPro); }
/** * 获取定价计划第二天推广的viewtime */ public static function getNextDaySpreadTime() { if (isset(self::$_nextDayViewtime)) { return self::$_nextDayViewtime; } $nextDay = date("Ymd", strtotime("+1 day")); $nextDayTime = strtotime($nextDay); self::$_nextDayViewtime = $nextDayTime; return $nextDayTime; }
/** * 获取房源定价推广的状态 * * @param $propId 房源id * @return -2,错误状态-1,不在推广,1-正常推广,2-房源本身被删除, 3-第二天推广 * 不在推广包括 账户没钱停止,手动停止,房源从推广计划中删除, 房源违规, 房源到期, 计划删除 */ public function getPropFixedStatus($propId, $cityId) { $return = array("status" => -1, "msg" => "不在推广"); //获取房源计划关系 if (isset(self::$propRelationsByPropId)) { $relationInfo = self::$propRelationsByPropId[$propId]; } else { $relationInfo = $this->getProSpreadRelationByProId($propId, $cityId); if (empty($relationInfo)) { return $return; } else { self::$propRelationsByPropId = $relationInfo; } } switch ($relationInfo['Status']) { case 1: //获取对应的计划状态信息 $planId = $relationInfo['PlanId']; $planBll = new Bll_Fixedspread_AjkFixedSpread(); $planInfo = $planBll->getStaticPlanById($planId); if (isset($planInfo[-9999])) { $return = array("status" => -2, "msg" => "数据库错误"); break; } if (empty($planInfo)) { $return = array("status" => -2, "msg" => "计划信息为空"); break; } $planStatus = Bll_Fixedspread_AjkFixedSpread::getFixedPlanStatus($planInfo['Status'], $planInfo['ViewTime']); //1. 刪除 2.推广中 3.第二天推广 4.账户没钱停止 5.手动停止 switch ($planStatus) { case 1: $return = array("status" => -1, "msg" => "计划被删除"); break; case 2: $return = array("status" => 1, "msg" => "正常推广"); break; case 3: $return = array("status" => 3, "msg" => "房源第二天推广"); break; case 4: $return = array("status" => -1, "msg" => "账户没钱停止计划"); break; case 5: $return = array("status" => -1, "msg" => "手动停止计划"); break; default: $return = array("status" => -2, "msg" => "未知状态"); break; } break; case 2: $return = array("status" => -1, "msg" => "房源已从计划中删除"); break; case 3: $return = array("status" => -1, "msg" => "房源违规"); break; case 4: $return = array("status" => -1, "msg" => "房源到期"); break; case 5: $return = array("status" => 2, "msg" => "删除房源"); break; case 6: $return = array("status" => -1, "msg" => "计划被删除"); break; default: $return = array("status" => -2, "msg" => "未知状态"); break; } return $return; }
public function handle_request_internal() { if (!Bll_City::isShowCaseCity(static::$intBrokerCityID)) { $this->redirect('/user/combo/brokerhome'); exit; } $objRequest = APF::get_instance()->get_request(); $cityID = self::$BrokerInfo['BaseInfo']['CITYID']; $objRequest->set_attribute('PayType', self::$BrokerInfo['BaseInfo']['PAYTYPE']); $tmp = array('cityId' => $cityID, 'status' => 1, 'startDate' => date('Ymd')); $cityPrice = Bll_Broker_ConfigCityPrice::getInstance()->getCityPrice($tmp, Const_ShowcaseOrders::SALE_DB); $todayPrice = round($cityPrice->discountPrice / 100, 2); $intBrokerID = $objRequest->getBrokerId(); $userId = $objRequest->getUserId(); $data = array('brokerId' => $intBrokerID); $orderinfo = Bll_Broker_ShowcaseOrders::getInstance()->getBrokerOrders($data, $this->db); if (!$orderinfo) { $this->toManage('/ajkbroker/showcase/esf/'); } $lavedays = ceil((strtotime($orderinfo->endDate) - strtotime(date('Ymd'))) / 3600 / 24); if ($orderinfo->isStop == 1 || $lavedays < 0) { $order_status = 'stop'; } else { $objRequest->set_attribute('lavedays', $lavedays); $objRequest->set_attribute('lastday', date('Y-m-d', strtotime($orderinfo->endDate))); $order_status = 'open'; } $objRequest->set_attribute('order_status', $order_status); $objRequest->set_attribute('todayPrice', $todayPrice); $params = APF::get_instance()->get_request()->get_parameters(); $days = intval($params['days']); //status=2是停止,status=1是续费 if ($params['status'] == 2) { if ($orderinfo->isStop == 0) { $stopstatus = Bll_Broker_ShowcaseOrders::getInstance()->stopBrokerOthers($orderinfo, $cityPrice->discountPrice, $this->db); if ($stopstatus['status']) { $this->toManage(); } else { $this->toError($stopstatus['msg']); } } else { $msg = '订单类型不能操作'; $this->toError($msg); } } elseif ($params['status'] == 1 && $days >= 1) { $BrokerMoney = Bll_Broker_ShowcaseOrders::getInstance()->getBrokerMoney($userId); if ($BrokerMoney < $todayPrice) { $this->toError(Const_ShowcaseOrders::MONEY_NOT_ENOUGH); } $Continueorder = Bll_Broker_ShowcaseOrders::getInstance()->continueBrokerOthers($orderinfo, $days, $cityPrice->discountPrice, $this->db); if ($Continueorder['status']) { $this->toManage(); } else { $this->toError($Continueorder['msg']); } } elseif ($params['status'] == 3) { $proIds = array(); if (!empty($params['rooms'])) { $proIds = explode(';', $params['rooms']); $filterProIds = Bll_Broker_ShowcaseAdSetPro::getInstance()->filterProIds($intBrokerID, $cityID, $this->db, $proIds); //有些房源不在线上展示 if (count($filterProIds) != count($proIds)) { $this->toError('有些房源没在线上推广,操作失败!'); } $res = Bll_Broker_ShowcaseAdSetPro::getInstance()->insertAdProsInfo($intBrokerID, $cityID, $proIds, $this->db); if (!$res['status']) { $this->toError($res['msg']); } else { //插入成功,跳转至管理页面 if ($orderinfo->isStop == 0) { $log = array(); $log['brokerId'] = $orderinfo->brokerId; $log['cityId'] = $orderinfo->cityId; $log['endDate'] = $orderinfo->endDate; $log['startDate'] = $orderinfo->startDate; $log['opType'] = Const_ShowcaseOrders::OPTYPE_6; $log['totalDays'] = ceil((strtotime($orderinfo->endDate) - strtotime($orderinfo->startDate)) / 3600 / 24) + 1; $log['createTime'] = time(); Bll_Broker_ShowcaseOrders::getInstance()->insertSetLog($log, $this->db); } $this->toManage(); } } } $orderCreated = date('Ymd', $orderinfo->createTime); if ($orderCreated < date('Ymd')) { $click = Bll_Broker_ShowcaseOrders::getInstance()->getBrokerClick($intBrokerID, date('Ymd', strtotime('-1 days')), $this->db); if (!$click->quantityCount) { $objRequest->set_attribute('YClick', 0); } else { $objRequest->set_attribute('YClick', $click->quantityCount); } $objRequest->set_attribute('IS_YClick', true); } $isCombo = Bll_Combo_HouseRelation::isComboCity($cityID); if ($isCombo['data']) { $comboList = Bll_Combo_HouseRelation::getHouseRelations($intBrokerID, Bll_Combo_HouseRelation::SITE_TYPE_AJK, 1); if (!empty($comboList)) { if (count($comboList) >= Const_ShowcaseOrders::SALE_PRO_MAX_COUNT) { $fixedProInfosCnt = Const_ShowcaseOrders::SALE_PRO_MAX_COUNT; } else { $fixedProInfosCnt = count($comboList); } } else { $fixedProInfosCnt = 0; } $proInfo = Bll_Broker_ShowcaseAdSetPro::getInstance()->getBrokerAdSalePropInfo($intBrokerID); $proIds = Bll_Broker_ShowcaseOrders::getInstance()->getObjFieldInfo($proInfo, 'propId'); $proInfos = Bll_House_EsfHouse::getHouseInfo($proIds, $cityID); $proList = Bll_Broker_ShowcaseAdSetPro::getInstance()->initComboEsfProData($proInfos, $comboList); } else { //获取经纪人计划 $brokerPlanInfo = BLL_Plan_EsfPropFixedPlanRelation::get_instance()->getBrokerEsfOnlinePlan($intBrokerID); if (!empty($brokerPlanInfo)) { //计划数据不为空 //计划IDs $planIds = Bll_Broker_ShowcaseOrders::getInstance()->getObjFieldInfo($brokerPlanInfo, 'id'); //定价推广房源 $fixedProInfos = Bll_Fixedspread_AjkFixedSpread::getFixedOnlineProByPlanIds($cityID, $planIds); $proIdsc = Bll_Broker_ShowcaseOrders::getInstance()->getObjFieldInfo($fixedProInfos, 'proId'); $proInfosc = Bll_House_EsfHouse::getHouseInfo($proIdsc, $cityID); if (!empty($proInfosc)) { if (count($proInfosc) >= Const_ShowcaseOrders::SALE_PRO_MAX_COUNT) { $fixedProInfosCnt = Const_ShowcaseOrders::SALE_PRO_MAX_COUNT; } else { $fixedProInfosCnt = count($proInfosc); } } else { $fixedProInfosCnt = 0; } } else { $fixedProInfosCnt = 0; } $proInfo = Bll_Broker_ShowcaseAdSetPro::getInstance()->getBrokerAdSalePropInfo($intBrokerID); $proIds = Bll_Broker_ShowcaseOrders::getInstance()->getObjFieldInfo($proInfo, 'propId'); $proInfos = Bll_House_EsfHouse::getHouseInfo($proIds, $cityID); $proStatus = Bll_Fixedspread_AjkFixedSpread::getFixedProBy($cityID, $proIds); $proList = Bll_Broker_ShowcaseAdSetPro::getInstance()->initEsfProData($proInfos, $proStatus, $planIds); } if (count($proList) > $fixedProInfosCnt) { $fixedProInfosCnt = count($proList); } $objRequest->set_attribute('type', 'ajk'); $objRequest->set_attribute('index', 2); //精选推广开关 $isChoice = Bll_City::isChoiceCity($cityID); $objRequest->set_attribute('isChoice', $isChoice); $objRequest->set_attribute('fixedProInfosCnt', $fixedProInfosCnt); $objRequest->set_attribute('proList', $proList); return 'Showcase_EsfManage'; }