/** * 上下架队列,二手房价格段变写房源日志 * * @param array $queue * @return array */ public static function upDownDeal($queue) { $priceInterval = json_decode($queue['remark'], true); if (!is_array($priceInterval) || empty($priceInterval)) { return array('status' => 0, 'msg' => 'remark解析JSON错误'); } if (!isset($priceInterval['id'])) { return array('status' => 0, 'msg' => '没有获取到价格段Id'); } $priceId = intval($priceInterval['id']); $priceIntervalInfo = Model_House_EsfPrice::get_price_by_id($priceId); if (empty($priceIntervalInfo)) { return array('status' => 0, 'msg' => '没有获取到价格段信息[' . $priceId . ']'); } $choicePlanList = Model_Plan_EsfAjkPropSpread::getChoicePlanByPrice($priceIntervalInfo['cityId'], $priceIntervalInfo['minPrice'], $priceIntervalInfo['maxPrice']); if (empty($choicePlanList)) { return array('status' => 1, 'msg' => sprintf('没有获取到推广、排队的精选计划[%d - %d -%d]', $priceIntervalInfo['cityId'], $priceIntervalInfo['minPrice'], $priceIntervalInfo['maxPrice'])); } $dealMark = array(); $remark = sprintf('价格段变更[queue_id: %d]', $queue['id']); foreach ($choicePlanList as $choicePlan) { $houseLog = static::buildHouseLog($choicePlan['propId'], $choicePlan['brokerId'], $choicePlan['cityId'], Const_ProPlanChangeType::PRICE_INTERVAL_CHANGE, Const_ProLogType::LOG_PRICE_INTERVAL_CHANGE, $remark); if (!Model_Log_HouseLogNew::create($houseLog, date('Ymd'))->save()) { $dealMark[] = sprintf('精选[%d]房源[%d]价格段变更写房源日志失败', $choicePlan['id'], $choicePlan['propId']); } else { $dealMark[] = sprintf('精选[%d]房源[%d]价格段变更写房源日志成功', $choicePlan['id'], $choicePlan['propId']); } } return array('status' => 1, 'msg' => sprintf('价格段变更房源日志写入完成,%s', implode(',', $dealMark))); }
/** * 初始化 坑位信息 * * @param $block_id * @param $city_id * @return array */ public static function init_bucket_info($type_code, $city_id, $price) { $priceIntervalInfo = Model_House_EsfPrice::get_price($city_id, $price); if (empty($priceIntervalInfo)) { return false; } return Model_Choice_EsfBlockBidBucket::init_bucket_info($type_code, $priceIntervalInfo['id'], $city_id); }
/** * 获取优惠价格信息 * * @param $communityId * @param $city_id * @param $price * @return array|bool */ public static function esf_get_favorable_price($communityId, $city_id, $price) { $priceIntervalInfo = Model_House_EsfPrice::get_price($city_id, $price); if (empty($priceIntervalInfo)) { return false; } $favorablePrice = Model_Choice_EsfFavorablePrice::get_favorable($communityId, $city_id, $priceIntervalInfo['id']); return $favorablePrice; }
/** * 根据ID 获取价格段信息 * * @param $id * @return array */ public static function get_price_by_id($id) { try { $priceInfo = Model_House_EsfPrice::data_access('')->filter('id', $id)->get_row(); } catch (Exception $e) { return array(); } if (is_null($priceInfo)) { return array(); } return $priceInfo; }
/** * 获取平均预算和点击 * * @param $communityId * @param $cityId * @param $price * @return array|bool */ public static function getBucketAverageClickBudget($communityId, $cityId, $price) { $priceIntervalInfo = Model_House_EsfPrice::get_price($cityId, $price); if (empty($priceIntervalInfo)) { return false; } $validDate = Model_Config_huTablesUploadStatus::getDate(self::STATICCLICKANDBUDGETCONFIGNAME); if (empty($validDate)) { $validDate = date("Y-m-d"); } $validDate = $validDate->calDt; return Model_Stats_EsfAverageClickBudget::getAverageClickBudget($communityId, $priceIntervalInfo['id'], date("Ymd", strtotime($validDate))); }
public function dealTask($task) { $currentUsedNum = $task['usedNum']; //获取价格信息 $priceIntervalInfo = Model_House_EsfPrice::data_access()->filter('id', $task['priceId'])->find_only(); if (empty($priceIntervalInfo)) { printf("价格段priceId:" . $task['priceId'] . "获取失败" . PHP_EOL); return false; } //获取实际计划数目 $trueUsedNum = Model_Plan_EsfAjkPropSpread::data_access()->filter("areacode", $task['typeCode'])->filter("smallprice", $priceIntervalInfo->minPrice)->filter("bigprice", $priceIntervalInfo->maxPrice)->filter("bidVersion", Model_Plan_EsfAjkPropSpread::CHOICEVERSION)->filter("model", Model_Plan_EsfAjkPropSpread::BLOCK_CHOICE)->filter_by_op('status', 'in', array(Model_Plan_EsfAjkPropSpread::ONLINE, Model_Plan_EsfAjkPropSpread::ONQUEUE))->count(); printf('正在处理 队列id %s, areaCode %s, priceId %s 结果是: userNum: %s, 实际: %s, 状态:%s' . PHP_EOL, $task['id'], $task['typeCode'], $task['priceId'], $currentUsedNum, $trueUsedNum, $currentUsedNum == $trueUsedNum ? 'success' : 'error'); if ($currentUsedNum == $trueUsedNum) { return true; } $result = Model_Choice_EsfBlockBidBucket::updateUsedNum($task['id'], $trueUsedNum, $task['usedNum']); printf('更新usedNum结果: %s' . PHP_EOL, $result ? '更新成功' : '更新失败'); return true; }
/** * 停止精选计划 * * @param $brokerId * @param $propId */ public function stopPlan($brokerId, $houseId) { try { //获取经纪人基本信息 $brokerBaseInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId); if (empty($brokerBaseInfo)) { $this->error(self::EMPTY_BROKER_ERROR, self::EMPTY_BROKER_ERROR_MSG); } $cityId = $brokerBaseInfo->cityId; $userId = $brokerBaseInfo->userId; //判断经纪人城市是否开通精选 if (!$this->checkChoiceOpen($brokerBaseInfo->cityId)) { $this->error(self::CHOICE_CLOSE_ERROR, self::CHOICE_CLOSE_ERROR_MSG); } //获取房源信息 $houseInfo = Bll_House_EsfHouse::getHouseBaseInfo($houseId, $cityId); if (empty($houseInfo)) { $this->error(self::PROP_NOT_EXIST_ERROR, self::PROP_NOT_EXIST_ERROR_MSG); } $houseInfo = $houseInfo[0]; //操作人验证 if ($houseInfo->userId != $userId) { $this->error(self::PROP_OPREATE_ACCESS_INVALID_ERROR, self::PROP_OPREATE_ACCESS_INVALID_ERROR_MSG); } //获取计划信息 $planInfo = Model_Plan_EsfAjkPropSpread::fitStopPlan($houseId); if (empty($planInfo)) { $this->error(self::CHOICE_PLAN_NOT_EXIST_ERROR, self::CHOICE_PLAN_NOT_EXIST_ERROR_MSG); } $housePrice = $planInfo->propriceint; $commId = $planInfo->commId; $planId = $planInfo->id; //获取价格段id $priceIdInfo = Model_House_EsfPrice::get_price($cityId, $housePrice); if (empty($priceIdInfo)) { $this->error(self::PROP_PRICE_UNKNOW_ERROR, self::PROP_PRICE_UNKNOW_ERROR_MSG); } $priceId = $priceIdInfo['id']; //停止计划的相关操作 $this->stopPlanAciton($brokerId, $planId, $commId, $priceId, $planInfo); return true; } catch (Exception $e) { if ($e instanceof Exception_BllErrorException) { $this->errorCode = $e->getCode(); } else { $this->errorCode = self::UNKNOW_ERROR; } $this->errorMsg = $e->getMessage(); return false; } }
public static function extendChoiceInfo($fixHouseList, $choiceHouseList, $cityId) { $priceSegmentList = Model_House_EsfPrice::getAllPriceInterval($cityId, Model_House_EsfPrice::TRADE_TYPE_SALE); // TODO 附加精选相关的信息 精选链接 精选提示 foreach ($fixHouseList as $houseId => &$houseInfo) { $houseInfo['choiceNotice'] = ''; if (isset($choiceHouseList[$houseId])) { $houseInfo['bidStatus'] = $choiceHouseList[$houseId]['status']; if ($choiceHouseList[$houseId]['status'] == 1) { $houseInfo['bidUrl'] = '/ajkbroker/user/choice/manage/ajk/#' . $houseId; $houseInfo['choiceNotice'] = '已精选'; continue; } elseif ($choiceHouseList[$houseId]['status'] == 11) { $houseInfo['bidUrl'] = '/ajkbroker/user/choice/manage/ajk/#' . $houseId; $houseInfo['choiceNotice'] = '排队中'; continue; } else { if ($choiceHouseList[$houseId]['status'] != 2) { $houseInfo['bidUrl'] = "/ajkbroker/user/choice/set/ajk/" . $houseInfo['proId'] . '/?act=1&rebid=1&plan_id=' . $choiceHouseList[$houseId]['id']; } $houseInfo['choiceNotice'] = $houseInfo['expiredDay'] >= 75 ? '可精选' : ''; } } if (!$houseInfo['isHighQulity']) { continue; } if ($houseInfo['expiredDay'] < 75) { continue; } $houseInfo['choiceNotice'] = '可精选'; foreach ($priceSegmentList as $priceSegment) { $housePrice = $houseInfo['proPrice'] * 10000; if ($priceSegment['minPrice'] < $housePrice && $housePrice <= $priceSegment['maxPrice']) { $houseInfo['proPriceId'] = $priceSegment['id']; break; } } $bucketInfo = Bll_Choice_EsfBidBucket::getBucketInfo($houseInfo['commId'], $houseInfo['cityId'], $houseInfo['proPriceId']); // $bucketInfo = Bll_Choice_EsfBidBucket::get_bucket_info($houseInfo['commId'], $houseInfo['cityId'], $houseInfo['proPriceInt']); if (false === $bucketInfo || empty($bucketInfo)) { continue; } if ($bucketInfo['usedNum'] == $bucketInfo['totalNum']) { $houseInfo['choiceNotice'] = '已排满'; } elseif ($bucketInfo['usedNum'] < $bucketInfo['totalNum'] && $bucketInfo['usedNum'] >= $bucketInfo['maxOnlineNum']) { $houseInfo['choiceNotice'] = '可排队'; } else { $houseInfo['choiceNotice'] = '可精选'; } } return $fixHouseList; }
/** * 页面停止推广操作封装 * * @param $planId * @return array */ public static function stop_plan($planId, $brokerId) { $rstArr = array('status' => 'ok'); //获取计划信息 $planInfo = Model_Plan_EsfAjkPropSpread::data_access()->filter_by_op('id', '=', $planId)->filter_by_op('status', '=', Model_Plan_EsfAjkPropSpread::ONLINE)->find_only(); if (empty($planInfo)) { return array('status' => 'fail', 'info' => 'empty plan'); } if ($brokerId != $planInfo->brokerId) { return array('status' => 'fail', 'info' => 'invalid broker'); } if (Model_Plan_EsfAjkPropSpread::COMM_CHOICE != $planInfo->model) { return array('status' => 'fail', 'info' => 'invalid house'); } $cityId = $planInfo->cityId; $propId = $planInfo->propId; //验证choice城市 if (!Bll_City::isChoiceCity($cityId)) { return array('status' => 'fail', 'info' => 'choice is not open'); } //获取房源信息 $pageAttribute['housesInfo'] = Bll_House_EsfHouse::getHouseBaseInfo($propId, $cityId); if (empty($pageAttribute['housesInfo'])) { return array('status' => 'fail', 'info' => 'empty house'); } //更新状态 $oldStatus = $planInfo->status; $planInfo->status = Model_Plan_EsfAjkPropSpread::HANDELSTOP; if (!$planInfo->save()) { return array('status' => 'fail', 'info' => 'update plan status fail'); } /** 坑位-1 只在计划关系被正确修改后才做 */ $housePrice = $planInfo->propriceint; $commId = $planInfo->commId; //获取价格段id $priceIdInfo = Model_House_EsfPrice::get_price($cityId, $housePrice); $priceId = $priceIdInfo['id']; //坑位减1 Model_Choice_EsfBidBucket::decrement_used_num($commId, $priceId); //放入队列 $ip = APF::get_instance()->get_request()->get_client_ip(); if (!Bll_Plan_Bid_EsfChoiceQueue::insert($brokerId, $planId, Model_Choice_ActionQueue::ENUM_STOP_BY_HAND, date('m'), $brokerId, '经纪人手动停止推广', $ip, $propId)) { return array('status' => 'fail', 'info' => 'insert chioce queue fail'); } //记录日志 $remark = sprintf("STATUS:%d=>%d", $oldStatus, Model_Plan_EsfAjkPropSpread::HANDELSTOP); Model_Plan_LogAjkPropspread::addNewLog($planId, $brokerId, Model_Plan_LogAjkPropspread::STOP, $remark); return $rstArr; }
public function run() { //根据游标获取一定数量的坑位信息 $bucketInfos = Model_Choice_EsfBidBucket::getBucketInfoById($this->cursor, 0, $this->limit); //无需要处理的数据 if (empty($bucketInfos)) { $this->setShStopFlag(); $this->setCursor(0); $this->logQuit("无需要处理的数据."); } //检验具体的坑位信息 foreach ($bucketInfos as $bucketInfo) { //获取价格信息 $priceIntervalInfo = Model_House_EsfPrice::data_access()->filter('id', $bucketInfo->priceId)->find_only(); if (empty($priceIntervalInfo)) { $this->addLogger(sprintf("坑位信息%d,价格段id:%d获取失败", $bucketInfo->id, $bucketInfo->priceId)); continue; } //获取实际计划数目 $planNum = Model_Plan_EsfAjkPropSpread::data_access()->filter("commId", $bucketInfo->communityId)->filter("smallprice", $priceIntervalInfo->minPrice)->filter("bigprice", $priceIntervalInfo->maxPrice)->filter("bidVersion", Model_Plan_EsfAjkPropSpread::CHOICEVERSION)->filter("model", Model_Plan_EsfAjkPropSpread::COMM_CHOICE)->filter_by_op('status', 'in', array(Model_Plan_EsfAjkPropSpread::ONLINE, Model_Plan_EsfAjkPropSpread::ONQUEUE))->count(); if ($planNum == $bucketInfo->usedNum) { if (isset($this->exceptionBucket[$bucketInfo->id])) { //移除已经正常的坑位标记 unset($this->exceptionBucket[$bucketInfo->id]); $this->addLogger(sprintf("坑位信息%d,坑位恢复到正常%d", $bucketInfo->id, $planNum)); } else { $this->addLogger(sprintf("坑位信息%d正常", $bucketInfo->id)); } //更新游标 $this->setCursor($bucketInfo->id); //更新异常文件 $this->exceptionBucketFile->coverLog(json_encode($this->exceptionBucket)); continue; } //坑位异常处理 if (isset($this->exceptionBucket[$bucketInfo->id])) { //坑位已异常 if ($this->exceptionBucket[$bucketInfo->id]["occur"] <= $this->repairOccurNum) { //达到警告线,需要修复数据 //已实际计划数为依据更新 if (Model_Choice_EsfBidBucket::updateUsedNum($bucketInfo->id, $planNum, $bucketInfo->usedNum)) { unset($this->exceptionBucket[$bucketInfo->id]); $this->addLogger(sprintf("坑位信息%d,更新坑位信息成功, SQL:%s", $bucketInfo->id, Model_Choice_EsfBidBucket::$lastSql)); } else { $this->addLogger(sprintf("坑位信息%d,更新坑位信息失败, SQL:%s", $bucketInfo->id, Model_Choice_EsfBidBucket::$lastSql)); continue; } } else { //未达到警告线,继续标记 //记录历史信息 if (isset($this->exceptionBucket[$bucketInfo->id]['history'])) { $history = $this->exceptionBucket[$bucketInfo->id]['history']; } else { $history = array(); } $history[] = $this->exceptionBucket[$bucketInfo->id]; //继续标记 $this->exceptionBucket[$bucketInfo->id] = array('planNum' => $planNum, 'usedNum' => $bucketInfo->usedNum, 'occur' => $this->exceptionBucket[$bucketInfo->id]["occur"] + 1); $this->exceptionBucket[$bucketInfo->id]['history'] = $history; //记录日志 $this->addLogger(sprintf("坑位信息%d,出现异常%s", $bucketInfo->id, json_encode($this->exceptionBucket[$bucketInfo->id]))); } } else { $this->exceptionBucket[$bucketInfo->id] = array('planNum' => $planNum, 'usedNum' => $bucketInfo->usedNum, 'occur' => 1); $this->addLogger(sprintf("坑位信息%d,出现异常%s", $bucketInfo->id, json_encode($this->exceptionBucket[$bucketInfo->id]))); } //更新异常文件 $this->exceptionBucketFile->coverLog(json_encode($this->exceptionBucket)); //更新游标 $this->setCursor($bucketInfo->id); } }
public function handle_request_internal() { /** * @var $request AJKRequest */ $request = APF::get_instance()->get_request(); /** * @var $response AJKResponse */ $response = APF::get_instance()->get_response(); $response->set_content_type('application/json', 'utf-8'); $houseIds = $request->get_parameter('houseIds'); if (empty($houseIds)) { echo json_encode($this->buildResponse('error', null, '请输入房源ID')); return; } if (!is_array($houseIds)) { $houseIds = explode(',', $houseIds); } $brokerId = static::$intBrokerID; $cityId = static::$intBrokerCityID; if (!Bll_City::isChoiceCity($cityId)) { echo json_encode($this->buildResponse('error', null, '只有精选城市才有这个功能')); return; } /** 获取房源信息 */ $tempHouseBaseInfoList = Bll_House_EsfHouse::getHouseInfoByHouseIdEx($brokerId, $houseIds, $cityId, array('proId', 'commId', 'proPriceId', 'proPrice', 'isVisible', 'isHighQulity', 'postDate')); /** 过滤掉不能精选的房源 */ $houseBaseInfoList = $this->filterCanChoiceHouseList($tempHouseBaseInfoList); if (empty($houseBaseInfoList)) { echo json_encode($this->buildResponse('error', null, '没有获取到房源信息')); return; } /** 房源的精选推广状态 */ $houseChoiceStateList = $this->initHouseChoiceState($houseIds); /** 获取城市价格段信息 */ $priceSegmentList = Model_House_EsfPrice::getAllPriceInterval($cityId, Model_House_EsfPrice::TRADE_TYPE_SALE); if (empty($priceSegmentList)) { echo json_encode($this->buildResponse('error', null, '获取城市房源价格段信息失败')); return; } /** 修正房源价格段ID, 对房源按小区和价格段ID分组 */ $groupCommunityPriceSegmentList = $this->groupCommunityPriceSegment($houseBaseInfoList, $priceSegmentList); /** 获取坑位信息 */ $bucketInfoList = array(); foreach ($groupCommunityPriceSegmentList as $key => $propIds) { list($communityId, $priceId) = explode('_', $key); $bucketInfo = Bll_Choice_EsfBidBucket::getBucketInfo($communityId, $cityId, $priceId); $bucketInfoList[$key] = $bucketInfo['usedNum'] < $bucketInfo['maxOnlineNum']; } //优先说明 3=低价 2=促销 1=推荐 低价>促销(折扣)>推荐(主营、热门、抢置顶) $brokerMarkHouseIds = $this->initBrokerMarkHouse($groupCommunityPriceSegmentList, $bucketInfoList); $result = array(); foreach ($houseIds as $key => $houseId) { if (!isset($brokerMarkHouseIds[$houseId])) { continue; } $reasonStr = ''; // from来源初始化 $query = array('from' => ''); if ($brokerMarkHouseIds[$houseId]['type'] == 1) { //推荐房源 $query['from'] = 'recommendsite'; if (!empty($brokerMarkHouseIds[$houseId]['rc_reason'])) { switch ($brokerMarkHouseIds[$houseId]['rc_reason']) { case 1: $reasonStr = '主营小区'; break; case 2: $reasonStr = '热门小区'; break; case 3: $reasonStr = '精选即可置顶'; break; case 4: $reasonStr = '主营、热门小区'; break; case 5: $reasonStr = '主营、精选即可置顶'; break; case 6: $reasonStr = '热门、精选即可置顶'; break; case 7: $reasonStr = '主营、热门、精选即可置顶'; break; } } } elseif ($brokerMarkHouseIds[$houseId]['type'] == 2) { //促销房源 $query['from'] = 'promotionsite'; if (!empty($brokerMarkHouseIds[$houseId]['zhekou'])) { $zk = $brokerMarkHouseIds[$houseId]['zhekou'] / 10; $reasonStr = '限时降价' . $zk . '折'; } else { $reasonStr = '限时降价'; } } elseif ($brokerMarkHouseIds[$houseId]['type'] == 3) { //低价房源 $query['from'] = 'lowpricesite'; $reasonStr = '价格便宜'; } if ($houseChoiceStateList[$houseId] > 0) { $query['act'] = 1; $query['rebid'] = 1; $query['plan_id'] = $houseChoiceStateList[$houseId]; } $result[$key] = array('id' => $houseId, 'url' => sprintf('/ajkbroker/user/choice/set/ajk/%d/?%s', $houseId, http_build_query($query)), 'recommend' => $brokerMarkHouseIds[$houseId]['type']); $result[$key]['reason'] = $reasonStr; } if (count($result) > 15) { $resultSlice = array_slice($result, 0, 15); } else { $resultSlice = $result; } foreach ($resultSlice as $key => $val) { if ($houseChoiceStateList[$val['id']] == -1) { unset($resultSlice[$key]); } } $params = array(); foreach ($resultSlice as $key => $val) { if ($brokerMarkHouseIds[$val['id']]['type'] == 1) { //推荐房源 $rcReason = $brokerMarkHouseIds[$val['id']]['rc_reason']; } elseif ($brokerMarkHouseIds[$val['id']]['type'] == 2) { //促销房源 $rcReason = '折扣'; } elseif ($brokerMarkHouseIds[$val['id']]['type'] == 3) { //低价房源 $rcReason = ''; } $params[] = array('brokerId' => $brokerId, 'cityId' => $cityId, 'proId' => $val['id'], 'type' => $val['recommend'], 'rcReason' => $rcReason, 'createTime' => $brokerMarkHouseIds[$val['id']]['createTime']); } if (!empty($params)) { $params = json_encode($params); APF::get_instance()->get_nlogger()->log('brokerMark', $params, true); } echo json_encode($this->buildResponse('ok', array_values($resultSlice), '')); }
public function handle_request_internal() { $brokerId = $this->_params['brokerId']; //经纪人信息 $brokerInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId); if (!$brokerInfo) { throw new Exception_BrokerNotFoundException('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS); } if (!Bll_Broker_HzBroker::isComboBroker($brokerId)) { throw new Exception_ISNotComboBrokerException('不是套餐经纪人。'); } // 套餐信息 $comboInfoList = Bll_Combo_Broker_BrokerComboInfo::getBrokerComboList($brokerId); $currentDate = time(); foreach ($comboInfoList as $comboInfo) { $startDate = strtotime($comboInfo['startTime']); $endDate = strtotime($comboInfo['endTime']); // 获取当前使用的套餐 if ($currentDate >= $startDate && $currentDate < $endDate && $comboInfo['salePropNum'] + $comboInfo['rentPropNum'] > 0) { $currentCombo = $comboInfo; $comboPropNum = $currentCombo['salePropNum']; if (Bll_Combo_Broker_BrokerComboInfo::isOpenUp($currentCombo)) { $comboPropNum = $currentCombo['rentPropNum'] + $currentCombo['salePropNum']; } break; } } $hasCombo = 0; //没有二手房套餐 if (!isset($currentCombo)) { return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('list' => array(), 'surplus' => 0, 'hasCombo' => $hasCombo)); } else { $hasCombo = 1; } $cityId = $brokerInfo->cityId; //获取套餐推广信息 $comboSpreadHouseList = Bll_Broker_Combo_ManageAjk::getComboSpreadHouseList($brokerId, $cityId); if (Bll_Combo_Broker_BrokerComboInfo::isOpenUp($currentCombo)) { $currentSpreadHouseCount = Bll_Combo_HouseRelation::getHouseCount($brokerId, Bll_Combo_Broker_BrokerComboInfo::SITE_TYPE_AJK, true); } else { $currentSpreadHouseCount = Bll_Combo_HouseRelation::getHouseCountEx($brokerId, $cityId, Bll_Combo_Broker_BrokerComboInfo::SITE_TYPE_AJK); } //套餐还可以推的房源数量 $surplus = $comboPropNum - $currentSpreadHouseCount; if (empty($comboSpreadHouseList)) { return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('list' => array(), 'surplus' => $surplus, 'hasCombo' => $hasCombo)); } //获取房源信息 $propIds = array_keys($comboSpreadHouseList); $propsInfo = Bll_House_EsfHouse::getHouseBaseInfo($propIds, $cityId); //批量获取默认图片 $propDefImages = Model_House_AjkPropertyData::getDafImages($propIds); //批量获取房源总点 $houseTodayClickInfo = Bll_House_EsfHouse::getHouseTodayComboClick($propIds); $houseClickInfo = Bll_House_EsfHouse::getComboHouseAccumulateClickByPropIds($brokerId, $propIds, $cityId); //房源竞价&精选计划 $propSpreadInfo = Model_Plan_EsfAjkPropSpread::getPlanByPropIds($propIds); // 获取城市价格段信息 $priceSegmentList = Model_House_EsfPrice::getAllPriceInterval($cityId, Model_House_EsfPrice::TRADE_TYPE_SALE); //是否是精选城市,是否精选分离 $cityIsChoice = Bll_City::isChoiceCity($cityId, Const_Site::ANJUKE); $cityIsChoiceIndependent = Bll_City::isChoiceIndependentCity($cityId, Const_Site::ANJUKE); //拼接房源列表中房源数据 $list = array(); foreach ($propsInfo as $prop) { $row = array(); $row['propId'] = $prop->proId; $row['title'] = $prop->proName; $row['commId'] = $prop->commId; $row['commName'] = $prop->commName; $row['roomNum'] = $prop->roomNum; $row['hallNum'] = $prop->hallNum; $row['area'] = round($prop->areaNum); $row['toiletNum'] = $prop->toiletNum; $row['price'] = intval($prop->proPrice); $row['priceUnit'] = '万'; $row['isBid'] = 0; $row['isChoice'] = 0; $row['isMoreImg'] = $prop->isHighQulity; $row['isPhonePub'] = $prop->uriCode == 'mobile.asyn' || $prop->uriCode == 'mobile-ajk-broker.asyn' ? 1 : 0; $row['isVisible'] = isset($houseInfo['isVisible']) ? $houseInfo['isVisible'] : 1; //0-违规房源 1-非违规房源 $row['createTime'] = $prop->postDate; //房源发布时间 $row['imgUrl'] = Model_House_AjkPropertyData::imageUrl($propDefImages[$prop->proId]); if ($prop->commitionType == 2) { $row['isEntrust'] = 1; } else { $row['isEntrust'] = 0; } $row['totalClicks'] = $houseTodayClickInfo[$prop->proId] + $houseClickInfo[$prop->proId]; if (isset($propSpreadInfo[$prop->proId])) { if ($propSpreadInfo[$prop->proId]->bidVersion == 1 && ($propSpreadInfo[$prop->proId]->status == 1 || $propSpreadInfo[$prop->proId]->status == 11)) { $row['isBid'] = 1; } elseif ($propSpreadInfo[$prop->proId]->bidVersion == 2 && ($propSpreadInfo[$prop->proId]->status == 1 || $propSpreadInfo[$prop->proId]->status == 11)) { $row['isChoice'] = 1; } } $choiceStatusRecommend = Bll_House_EsfHouse::getEsfChoiceStatusAndRecommend($priceSegmentList, $propSpreadInfo, $prop, $cityIsChoice, $cityIsChoiceIndependent); $row['choiceStatus'] = $choiceStatusRecommend['choiceStatus']; $row['choiceStatusName'] = $choiceStatusRecommend['choiceStatusName']; $row['choiceRecommend'] = $choiceStatusRecommend['choiceRecommend']; $list[] = $row; } // 排序 usort($list, function ($a, $b) { if ($a['createTime'] == $b['createTime']) { return 0; } return $a['createTime'] > $b['createTime'] ? -1 : 1; }); return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('list' => $list, 'surplus' => $surplus > 0 ? $surplus : 0, 'hasCombo' => $hasCombo)); }
/** * 同类房源对比 * * @param int $houseId * @param int $cityId * @param int $communityId * @param int $price * @return array */ public static function getHouseStatisticsInfo($houseId, $cityId, $communityId, $price) { /** 房源的价格段信息 */ $priceInterval = Model_House_EsfPrice::getPriceInterval($cityId, $price); /** 过去7天房源累计VPPV排名 */ $houseRankInfo = Model_Stats_PropRankEsfLastSevenDaysDtl::getHouseLast7DaysDtl($houseId, $priceInterval['id']); /** 过去七天累计有效vppv最高的那套房源的有效vppv */ $communityRankInfo = Model_Stats_CommunityPriceEsfLastSevenDaysSummary::getCommunity7DayDlt($communityId, $priceInterval['id']); $houseClick = empty($houseRankInfo) ? 0 : $houseRankInfo['totalVPPVLastSevenDays']; $communityAvgClick = !empty($communityRankInfo) && $communityRankInfo['totalPMPropLastWeek'] ? floor($communityRankInfo['totalVPPVLastWeek'] / $communityRankInfo['totalPMPropLastWeek']) : 0; $communityMaxClick = empty($communityRankInfo) ? 0 : $communityRankInfo['maxVPPV']; $houseRank = $communityRankInfo['totalPMPropLastWeek'] == 0 || (empty($houseRankInfo) || $houseRankInfo['rank'] == 0) ? 0 : round((1 - $houseRankInfo['rank'] / $communityRankInfo['totalPMPropLastWeek']) * 100); return array('houseClick' => $houseClick, 'communityAvgClick' => $communityAvgClick, 'communityMaxClick' => $communityMaxClick, 'rank' => $houseRank); }
public function handle_request_internal() { $brokerId = $this->_params['brokerId']; $brokerInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId); if (!$brokerInfo) { throw new Exception_BrokerNotFoundException('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS); } if (!Bll_Broker_HzBroker::isComboBroker($brokerId)) { throw new Exception_ISNotComboBrokerException('不是套餐经纪人。'); } //获取套餐推广信息 $cityId = $brokerInfo->cityId; $comboSpreadHouseList = Bll_Broker_Combo_ManageAjk::getComboSpreadHouseList($brokerId, $cityId); $comboSpreadHouseIds = array_keys($comboSpreadHouseList); //获取精选推广信息 $bll = new BLL_Choice_EsfAPPAPIChoice(); $choiceHouseList = $bll->getBrokerPropChoiceInfo($brokerId); $choiceHouseIds = array(); foreach ($choiceHouseList as $list) { foreach ($list as $v) { $choiceHouseIds[] = $v['propId']; } } //获取经纪人所有房源信息 $tempHouseInfoList = Bll_House_EsfHouse::getBrokerAllPropInfoList($brokerId, $cityId); if (empty($tempHouseInfoList)) { return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('propertyList' => array())); } //未推广房源列表 $tempNoSpreadHouseList = array(); $noSpreadHouseIds = array(); foreach ($tempHouseInfoList as $houseInfo) { if (!in_array($houseInfo['proId'], $comboSpreadHouseIds) && !in_array($houseInfo['proId'], $choiceHouseIds)) { $houseInfo['illegal'] = isset($houseInfo['isVisible']) ? $houseInfo['isVisible'] : 1; //0-违规房源 1-非违规房源 $tempNoSpreadHouseList[$houseInfo['proId']] = $houseInfo; $noSpreadHouseIds[] = $houseInfo['proId']; } } // 获取城市价格段信息 $priceSegmentList = Model_House_EsfPrice::getAllPriceInterval($cityId, Model_House_EsfPrice::TRADE_TYPE_SALE); /** 过滤违规房源 */ $tmpIllegalList = array(); if (!$noSpreadHouseIds) { return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('propertyList' => array())); } foreach ($tempNoSpreadHouseList as $propId => $houseInfo) { if ($houseInfo['illegal'] == 0 && $houseInfo['expireWorker'] != 'propertyReport') { $tmpIllegalList[$propId] = $houseInfo; unset($tempNoSpreadHouseList[$propId]); } } //是否是精选城市,是否精选分离 $cityIsChoice = Bll_City::isChoiceCity($cityId, Const_Site::ANJUKE); $cityIsChoiceIndependent = Bll_City::isChoiceIndependentCity($cityId, Const_Site::ANJUKE); //违规房源排在前面 $noSpreadHouseList = array_merge($tmpIllegalList, $tempNoSpreadHouseList); $propDefImages = Model_House_AjkPropertyData::getDafImages($noSpreadHouseIds); $propertyList = array(); foreach ($noSpreadHouseList as $houseInfo) { $row = array(); $row['propId'] = $houseInfo['proId']; $row['title'] = $houseInfo['proName']; $row['commId'] = $houseInfo['commId']; $row['commName'] = $houseInfo['commName']; $row['roomNum'] = $houseInfo['roomNum']; $row['hallNum'] = $houseInfo['hallNum']; $row['area'] = round($houseInfo['areaNum']); $row['toiletNum'] = $houseInfo['toiletNum']; $row['price'] = intval($houseInfo['proPrice']); $row['priceUnit'] = '万'; $row['isBid'] = 0; $row['isChoice'] = 0; $row['isMoreImg'] = $houseInfo['isHighQulity']; $row['isPhonePub'] = $houseInfo['uriCode'] == 'mobile.asyn' || $houseInfo['uriCode'] == 'mobile-ajk-broker.asyn' ? 1 : 0; $row['isVisible'] = $houseInfo['illegal']; //0-违规房源 1-非违规房源 $row['createTime'] = $houseInfo['postDate']; //房源发布时间 $row['imgUrl'] = $row['imgUrl'] = Model_House_AjkPropertyData::imageUrl($propDefImages[$houseInfo['proId']]); if ($houseInfo['commitionType'] == 2) { $row['isEntrust'] = 1; } else { $row['isEntrust'] = 0; } //精选状态: 可精选;可排队;精选中;排队中 $choiceStatusRecommend = Bll_House_EsfHouse::getEsfChoiceStatusAndRecommend($priceSegmentList, array(), $houseInfo, $cityIsChoice, $cityIsChoiceIndependent); $row['choiceStatus'] = $choiceStatusRecommend['choiceStatus']; $row['choiceStatusName'] = $choiceStatusRecommend['choiceStatusName']; $row['choiceRecommend'] = $choiceStatusRecommend['choiceRecommend']; $propertyList[] = $row; } //排序 usort($propertyList, function ($a, $b) { if ($a['createTime'] == $b['createTime']) { return 0; } return $a['createTime'] > $b['createTime'] ? -1 : 1; }); return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('propertyList' => $propertyList)); }
/** * 小区合并修改计划信息 * * @param $queue * @return bool */ public function communityMerge($queue) { if ($queue['planId'] == 0 || $queue['proId'] == 0) { $this->setMsg('房源Id、计划Id不能为空'); return false; } /** 判断计划状态 */ $planInfo = Model_Plan_EsfAjkPropSpread::getPlanInfoByIdEx($queue['planId']); if ($planInfo['tradetype'] != 1 || $planInfo['bidVersion'] != 2) { $this->setMsg(sprintf('计划[%d]信息错误[%d - %d]', $queue['planId'], $planInfo['tradetype'], $planInfo['bidVersion'])); return false; } if ($planInfo['status'] != Model_Plan_EsfAjkPropSpread::ONLINE && $planInfo['status'] != Model_Plan_EsfAjkPropSpread::ONQUEUE) { $this->setMsg(sprintf('计划[%d]不在推广、排队中[%d]', $queue['planId'], $planInfo['status'])); return true; } if ($planInfo['propId'] != $queue['proId']) { $this->setMsg(sprintf('房源Id[%d - %d]不一致', $queue['proId'], $planInfo['propId'])); return true; } $houseInfo = Bll_House_EsfHouse::getHouseBaseInfoEx($queue['proId'], $planInfo['cityId']); if (empty($houseInfo)) { $this->setMsg(sprintf('房源[%d]信息没有获取到', $queue['proId'])); return true; } $housePrice = intval($houseInfo['proPrice'] * 10000); $priceIntervalInfo = Model_House_EsfPrice::get_price($planInfo['cityId'], $housePrice); if (empty($priceIntervalInfo)) { $this->setMsg(sprintf('房源[%d]没有获取到价格段信息[%d]', $queue['proId'], $housePrice)); return true; } $priceId = $priceIntervalInfo['id']; $communityId = $houseInfo['commId']; $data = array('commId' => $communityId); if (!Model_Plan_EsfAjkPropSpread::updatePlan($queue['planId'], $data)) { $this->setMsg(sprintf('更新计划[%d]信息[%s]失败', $queue['planId'], json_encode($data))); return false; } $bucketInfo = Model_Choice_EsfBidBucket::get_bucket_info($communityId, $priceId); if (empty($bucketInfo)) { Model_Choice_EsfBidBucket::init_bucket_info($communityId, $priceId, $planInfo['cityId']); } Model_Choice_EsfBidBucket::increment_used_num_ex($communityId, $priceId); $this->setMsg(sprintf('更新计划[%d]信息[%s]成功', $queue['planId'], json_encode($data))); $planInfo['proPriceInt'] = $planInfo['propriceint']; //todo 添加房源日志 type 小区合并,区域板块变更 Model_Log_HouseLogNew::create(array('houseId' => $queue['propId'], 'planId' => $queue['planId'], 'brokerId' => $queue['brokerId'], 'cityId' => $planInfo['cityId'], 'type' => Const_ProLogType::LOG_COMMUNITY_MERGE_PROP_CHANGE, 'changeType' => Const_ProPlanChangeType::COMM_MERGE_PROP_CHANGE, 'remark' => '小区合并,精选房源信息变更', 'operatorId' => $this->qInfo['operationId'], 'siteType' => 1), date('Ymd'))->save(); return $this->choiceComputeRank(array_merge($planInfo, $data)); }
/** * 金铺-精选房源设置页面 * * @param int $brokerId * @param int $cityId * @param int $houseId * @param array $params * * @return array */ public static function esf_setting($brokerId, $cityId, $houseId, $userId, $params = array()) { $pageAttribute = array(); //获取精选推广预算 $brokerInfo = Bll_BrokerBaseBll::get_instance()->get_broker_info($brokerId); $brokerCompanyId = $brokerInfo['BaseInfo']['COMPANYID']; $choiceSet = APF::get_instance()->get_config('choice_set'); //根据经纪人公司不同有不同的预算 if (isset($choiceSet[$brokerCompanyId]) && !empty($choiceSet[$brokerCompanyId])) { $pageAttribute['min_budget'] = $choiceSet[$brokerCompanyId]['ajk']['ESF_CHOICE_MIN_BUDGET']; $pageAttribute['max_budget'] = $choiceSet[$brokerCompanyId]['ajk']['ESF_CHOICE_MAX_BUDGET']; } else { $pageAttribute['min_budget'] = $choiceSet['default']['ajk']['ESF_CHOICE_MIN_BUDGET']; $pageAttribute['max_budget'] = $choiceSet['default']['ajk']['ESF_CHOICE_MAX_BUDGET']; } self::setChoiceNum($cityId); //判断当前经纪人已经精选推广的房源数 if (isset($params['act']) && isset($params['rebid'])) { if (self::checkEsfBidChoiceFull($brokerId, $cityId, 1)) { //检查二手房精选是否达到最大 return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '最多精选推广' . self::$all_esf_plan_num . '套房源'); } } else { if (self::checkEsfBidChoiceFull($brokerId, $cityId)) { return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '最多精选推广' . self::$all_esf_plan_num . '套房源'); } } /** 经纪人重新推广房源 */ if (isset($params['act']) && isset($params['rebid'])) { //在精选管理页就已经设置时候是重新推广 $planInfo = Model_Plan_EsfAjkPropSpread::getChoicePlanInfoByHouseid($houseId); if ($planInfo->status == Model_Plan_EsfAjkPropSpread::ONLINE || $planInfo->status == Model_Plan_EsfAjkPropSpread::ONQUEUE) { return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '房源已经精选'); } $pageAttribute['plan_id'] = $params['plan_id']; $pageAttribute['rebid'] = true; } $balance = self::get_broker_balance_by_broker_id($brokerId); //获取经纪人账户余额 $pageAttribute['balance'] = $balance; if ($balance > 0) { $balance = sprintf('%.2f', $balance / 100); } $pageAttribute['balance_fmt'] = $balance; //获取房源信息 $pageAttribute['housesInfo'] = Bll_House_EsfHouse::getHouseBaseInfo($houseId, $cityId); if (empty($pageAttribute['housesInfo'])) { return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '房源不存在!'); } $houseInfo = $pageAttribute['housesInfo'][0]; if ($houseInfo->userId != $userId) { return array('err_no' => self::BID_FAIL_QUALITY_OR_NEW, 'err_msg' => '房源不属于当前操作人'); } if ($houseInfo->isVisible != 1) { return array('err_no' => self::BID_FAIL_QUALITY_OR_NEW, 'err_msg' => '房源是违规房源,不可以参加精选房源推广'); } if ($houseInfo->isHighQulity == 0) { return array('err_no' => self::BID_FAIL_QUALITY_OR_NEW, 'err_msg' => '多图、新发15天房源才能参与精选推广'); } if (date('Ymd', strtotime('-15 days')) > date('Ymd', $houseInfo->postDate)) { return array('err_no' => self::BID_FAIL_QUALITY_OR_NEW, 'err_msg' => '多图、新发15天房源才能参与精选推广'); } /** 判断是否是精选开放城市 */ if (!Bll_City::isChoiceIndependentCity($cityId, Const_Site::ANJUKE)) { /** 判断是在套餐推广中 */ $houseState = Bll_Combo_HouseRelation::getOnlineRelationByHouseId($houseId, Bll_Combo_HouseRelation::SITE_TYPE_AJK); if (empty($houseState)) { return array('err_no' => self::BID_FAIL_QUALITY_OR_NEW, 'err_msg' => '该房源不在推广中'); } } //判断是否已在竞价计划中 $planInfo = Model_Plan_EsfAjkPropSpread::getChoicePlanInfoByHouseid($houseId); if (!empty($planInfo) && !isset($params['act']) && !isset($params['rebid'])) { return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '房源已经精选'); } $pageAttribute['title'] = sprintf("%s,%d室%d厅%d卫,%d平,%.2f万", $houseInfo->commName, $houseInfo->roomNum, $houseInfo->hallNum, $houseInfo->toiletNum, intval($houseInfo->areaNum), $houseInfo->proPrice); $pageAttribute['community_name'] = $houseInfo->commName; $housePrice = intval($houseInfo->proPrice * 10000); //获取坑位信息 $bucketInfo = Bll_Choice_EsfBidBucket::get_bucket_info($houseInfo->commId, $cityId, $housePrice); //获取坑位信息 if (empty($bucketInfo)) { Bll_Choice_EsfBidBucket::init_bucket_info($houseInfo->commId, $cityId, $housePrice); $bucketInfo = Bll_Choice_EsfBidBucket::get_bucket_info($houseInfo->commId, $cityId, $housePrice); } if ($bucketInfo['usedNum'] < $bucketInfo['maxOnlineNum']) { $pageAttribute['hidden']['show'] = 1; } $pageAttribute['bucket_total'] = $bucketInfo['totalNum']; $pageAttribute['bucket_used'] = $bucketInfo['usedNum']; $pageAttribute['bucket_used_num'] = $bucketInfo['usedNum']; $pageAttribute['bucket_total_num'] = $bucketInfo['totalNum']; $pageAttribute['bucket_max_online_num'] = $bucketInfo['maxOnlineNum']; $priceInfo = Model_House_EsfPrice::get_price_by_id($bucketInfo['priceId']); $pageAttribute['price_title'] = sprintf("%d-%d万", intval($priceInfo['minPrice'] / 10000), intval($priceInfo['maxPrice'] / 10000)); //价格 $clickPrice = Bll_Service_Choice::ajkClickPrice(array('brokerId' => $brokerId, 'cityId' => $cityId, 'price' => $housePrice, 'commId' => $houseInfo->commId)); if ($clickPrice['status'] == 'error') { return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '服务器繁忙,请重试(code: -' . __LINE__ . ')'); } if ($clickPrice['realTradeAmount'] != $clickPrice['shouldTradeAmount']) { $pageAttribute['favorable'] = true; $pageAttribute['price'] = round($clickPrice['realTradeAmount'] / 100, 2); $pageAttribute['origin_price'] = round($clickPrice['shouldTradeAmount'] / 100, 2); $pageAttribute['favorable_end_time'] = date('Y-m-d', strtotime($clickPrice['rebateEndTime'])); } else { $pageAttribute['favorable'] = false; $pageAttribute['price'] = round($clickPrice['realTradeAmount'] / 100, 2); } $clickAndBudget = Bll_Choice_EsfBidBucket::getBucketAverageClickBudget($houseInfo->commId, $cityId, $housePrice); //获取坑位的平均点击的预算 if (!empty($clickAndBudget)) { $pageAttribute['averageClick'] = $clickAndBudget['averageClick']; $pageAttribute['averageBudget'] = $clickAndBudget['averageBudget'] / 100; } /**重组板块精选url**/ $bidPlanList = Bll_Plan_Bid_AjkPlan::getBrokerValidPlanListByhouseId($houseId, $brokerId, $cityId, true); //板块加价格 $bidPlanList = $bidPlanList[0]; if (isset($bidPlanList)) { $blockInfo['bidStatus'] = $bidPlanList['status']; if ($bidPlanList['status'] == 1) { $bidUrl = '/ajkbroker/user/choice/manage/ajk/#' . $houseId; } elseif ($bidPlanList['status'] == 11) { $bidUrl = '/ajkbroker/user/choice/manage/ajk/#' . $houseId; } else { if ($bidPlanList['status'] != 2) { $bidUrl = "/ajkbroker/user/choice/blockset/ajk/" . $houseInfo['proId'] . '/?act=1&rebid=1&plan_id=' . $bidPlanList['id']; } } } else { $bidUrl = "/ajkbroker/user/choice/blockset/ajk/" . $houseInfo['proId']; } $pageAttribute['bidUrl'] = $bidUrl; return $pageAttribute; }
public function handle_request_internal() { $brokerId = $this->_params['brokerId']; $propId = $this->_params['propId']; //检查经纪人是否存在 $brokerInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId); if (!$brokerInfo) { throw new Exception_Broker_NotFound('BrokerId: ' . $brokerId); } // 判断城市是否开通竞价业务 $cityId = $brokerInfo->cityId; if (!Bll_City::isBidCity($cityId)) { throw new Exception_City_NotBidCity('CityId: ' . $cityId); } //房子的竞价计划 $bidPlan = Model_Plan_EsfAjkPropSpread::getBidPlanInfoByHouseid($propId); if (empty($bidPlan)) { //房源信息 $propInfo = Bll_House_EsfHouse::getHouseBaseInfo($propId, $brokerInfo->cityId); if (!$propInfo[0]->isHighQulity) { throw new Exception_Property_NotMultiImages("Anjuke propId: {$propId}"); } throw new Exception_BidPlan_NotFound('PropId: ' . $propId); } //房源总点击 $bidClickInfo = Model_Plan_HpProStatsDay::getPropClicks($propId, $brokerInfo->cityId); $data = array(); $data['totalClicks'] = $bidClickInfo[$propId]['totalClicks']; //房源竞价总点击 $data['todayClicks'] = Model_plan_HpProStatsDay::getPropClickByDate($propId, $cityId, date('Ymd')); //今日点击 $data['planId'] = $bidPlan->id; $priceInfo = Model_House_EsfPrice::get_price($cityId, $bidPlan->propriceint); $data['minClickPrice'] = $priceInfo['vPrice']; //最小出价 $data['minClickPriceUnit'] = '元'; //最小出价 //推广中 排队中 if ($bidPlan->status == Model_Plan_EsfAjkPropSpread::ONLINE || $bidPlan->status == Model_Plan_EsfAjkPropSpread::ONQUEUE) { $data['planStatus'] = 1; // 推广中 or 排队中 $data['budget'] = $bidPlan->budget / 100; //预算 $data['budgetUnit'] = '元'; $consume = Model_plan_HpProStatsDay::getPlanAmounts($bidPlan->id, $cityId); $data['budgetRemain'] = ($bidPlan->budget - $consume) / 100; $data['budgetRemainUnit'] = '元'; $data['clickPrice'] = $bidPlan->offer / 100; //出价 $data['clickPriceUnit'] = '元'; $data['rankMsg'] = '排队中'; if ($bidPlan->status == Model_Plan_EsfAjkPropSpread::ONLINE) { //排名 $data['rank'] = $this->getPpcSaleRankBll($propId, $bidPlan->commId, $bidPlan->smallprice, $bidPlan->bigprice, $bidPlan->commsHpratioA, 3); $data['rankMsg'] = '推广中'; } } else { $data['planStatus'] = 2; //已暂停 $data['budget'] = 0; $data['budgetUnit'] = '元'; $data['budgetRemain'] = 0; $data['budgetRemainUnit'] = '元'; $data['clickPrice'] = 0; $data['clickPriceUnit'] = '元'; $data['rankMsg'] = '已暂停'; } return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => $data); }
public function handle_request_internal() { /** * @var $request AJKRequest */ $request = APF::get_instance()->get_request(); /** * @var $response AJKResponse */ $response = APF::get_instance()->get_response(); $response->set_content_type('application/json', 'utf-8'); $houseIds = $request->get_parameter('houseIds'); if (empty($houseIds)) { echo json_encode($this->buildResponse('error', null, '请输入房源ID')); return; } if (!is_array($houseIds)) { $houseIds = explode(',', $houseIds); } $brokerId = static::$intBrokerID; $cityId = static::$intBrokerCityID; if (!Bll_City::isChoiceCity($cityId)) { echo json_encode($this->buildResponse('error', null, '只有精选城市才有这个功能')); return; } /** 获取房源信息 */ $tempHouseBaseInfoList = Bll_House_EsfHouse::getHouseInfoByHouseIdEx($brokerId, $houseIds, $cityId, array('proId', 'commId', 'proPriceId', 'proPrice', 'isVisible', 'isHighQulity', 'postDate')); /** 过滤掉不能精选的房源 */ $houseBaseInfoList = $this->filterCanChoiceHouseList($tempHouseBaseInfoList); if (empty($houseBaseInfoList)) { echo json_encode($this->buildResponse('error', null, '没有获取到房源信息')); return; } /** 房源的精选推广状态 */ $houseChoiceStateList = $this->initHouseChoiceState($houseIds); /** 获取城市价格段信息 */ $priceSegmentList = Model_House_EsfPrice::getAllPriceInterval($cityId, Model_House_EsfPrice::TRADE_TYPE_SALE); if (empty($priceSegmentList)) { echo json_encode($this->buildResponse('error', null, '获取城市房源价格段信息失败')); return; } /** 修正房源价格段ID, 对房源按小区和价格段ID分组 */ $groupCommunityPriceSegmentList = $this->groupCommunityPriceSegment($houseBaseInfoList, $priceSegmentList); /** 获取坑位休息 */ $bucketInfoList = array(); foreach ($groupCommunityPriceSegmentList as $key => $propIds) { list($communityId, $priceId) = explode('_', $key); $bucketInfo = Bll_Choice_EsfBidBucket::getBucketInfo($communityId, $cityId, $priceId); $bucketInfoList[$key] = $bucketInfo['usedNum'] < $bucketInfo['maxOnlineNum']; } //优先说明,一元精选 > 抢置顶 > 最划算 /** 一元精选房源 */ $unitaryHouseIds = $this->initUnitaryHouse($groupCommunityPriceSegmentList, $bucketInfoList); /** 抢置顶房源 */ $topHouseIds = $this->initTopHouse($groupCommunityPriceSegmentList, $bucketInfoList); /** 最划算房源 */ $cheapestHouseIds = $this->initCheapestHouse($groupCommunityPriceSegmentList, $bucketInfoList); //合并数据 + 数组的值去重 $unitaryTopCheapHouseIds = array_unique(array_merge($unitaryHouseIds, $cheapestHouseIds, $topHouseIds)); $result = array(); foreach ($unitaryTopCheapHouseIds as $HouseId) { if ($houseChoiceStateList[$HouseId] == -1) { continue; } // recommend、from来源初始化 $query = array('from' => ''); $recommend = -1; if (in_array($HouseId, $unitaryHouseIds)) { //一元精选房源 $query['from'] = 'unitarysite'; $recommend = 3; } elseif (in_array($HouseId, $topHouseIds)) { //抢置顶房源 $query['from'] = 'topsite'; $recommend = 1; } elseif (in_array($HouseId, $cheapestHouseIds)) { //最划算房源 $query['from'] = 'cheapsite'; $recommend = 2; } if ($houseChoiceStateList[$HouseId] > 0) { $query['act'] = 1; $query['rebid'] = 1; $query['plan_id'] = $houseChoiceStateList[$HouseId]; } $result[] = array('id' => $HouseId, 'url' => sprintf('/ajkbroker/user/choice/set/ajk/%d/?%s', $HouseId, http_build_query($query)), 'recommend' => $recommend); } echo json_encode($this->buildResponse('ok', array_values($result), '')); }