private function dealTask($group) { if (!($areaCode = $group['areaCode'])) { return false; } if (!($areaInfo = Model_City_HzArea::getAreaByTypeCode($areaCode))) { return false; } $areaId = $areaInfo['parentId'] ? $areaInfo['parentId'] : 0; $blockId = $areaInfo['id'] ? $areaInfo['id'] : 0; $companyId = $group['cstCompanyId']; // 是否大客户 $isBigCompany = Model_Broker_HzBBrokerCompany::isBigCompany($companyId); // 获取销售资源分配 $hzResource = Model_PPC_HzCSalesResources::getResource($areaId, $blockId, $isBigCompany ? $companyId : 0); $sellerId = $hzResource ? $hzResource['sellerId'] : 0; // 判断公司是否已经同步,同步过的更新 $hzGroup = Model_Broker_HzBBrokerGroup::getBrokerGroupByGroupId($group['comanyId']); // 组装数据insert|update $content = array('shortName' => $group['shortCompanyName'], 'address' => $group['comanyAddr'], 'phone' => $group['comanyTel'], 'fax' => $group['comanyFax'], 'summery' => $group['comanySummery']); $data = array('groupId' => $group['comanyId'], 'name' => $group['comanyName'], 'storeId' => $group['realStoreId'], 'companyId' => $companyId, 'cityId' => $group['cityId'], 'contact' => $group['comanyLinkMan'], 'flag' => $group['isActive'], 'areaId' => $areaId, 'blockId' => $blockId, 'content' => json_encode($content), 'updated' => time(), 'mid' => 0, 'sellId' => $sellerId); if ($hzGroup) { $result = Model_Broker_HzBBrokerGroup::updateBrokerGroup($group['comanyId'], $data); printf('[%s] update: groupId: %s result: %s' . PHP_EOL, date('Y-m-d H:i:s'), $group['comanyId'], $result); return $result; } else { $result = Model_Broker_HzBBrokerGroup::addBrokerGroup($data); printf('[%s] add: result: %s' . PHP_EOL, date('Y-m-d H:i:s'), $result); return $result; } }
public static function getAreaByTypeCode($typeCode) { try { return Model_City_HzArea::data_access()->filter('typeCode', $typeCode)->get_row(); } catch (Exception $e) { return array(); } }
public function handle_request_internal() { $brokerId = $this->_params['brokerId']; $propId = $this->_params['propId']; // 获取Broker Mapping $brokerMapping = Model_Broker_MainBusiness::getMainBusinessByAjkBrokerId($brokerId); if (!$brokerMapping) { throw new Exception('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS); } // 获取房源信息 $prop = Model_House_HzProp::findByPropId($propId); if (!$prop) { throw new Exception('房源不存在', Const_APIStatus::E_PROP_NOT_EXISTS); } // 判断房源和经纪人关联关系 $contentBasic = $prop->getContentBasic(); if ($contentBasic['userid'] != $brokerMapping['hzBrokerid']) { throw new Exception('房源不属于该经纪人', Const_APIStatus::E_PROP_NOT_EXISTS); } $data = array(); $area_id = $contentBasic['areaid']; $block_id = $contentBasic['blockid']; $areaInfo = Model_City_HzArea::getAreaById($area_id); $area_name = $areaInfo['typeName']; $blockInfo = Model_City_HzArea::getAreaById($block_id); $block_name = $blockInfo['typeName']; $data['areaname'] = $area_name; $data['blockname'] = $block_name; $data['propId'] = $propId; $data['url'] = $this->build_base_url($contentBasic['cityid'], $propId); $data['title'] = $contentBasic['title']; $data['imgUrl'] = $prop->getDefaultImageUrl(); $data['commId'] = $contentBasic['commid']; $data['commName'] = $contentBasic['commname']; $data['roomNum'] = $contentBasic['roomnum']; $data['hallNum'] = $contentBasic['hallnum']; $data['toiletNum'] = $contentBasic['toilnetnum']; $data['area'] = round($contentBasic['areanum']); $data['price'] = round($contentBasic['pricenum']); $data['priceUnit'] = '元/月'; $data['isVisible'] = intval(!$prop->isIllegal()); $data['isMoreImg'] = intval($prop->isMultiImages()); $data['isBid'] = intval($prop->isBid()); $data['isChoice'] = intval($prop->isChoice()); $data['isPhonePub'] = intval($prop->isFromMobile()); $data['publishDays'] = $prop->getPublishedDays(); $data['publishDaysMsg'] = $prop->getPublishedDays() > 0 ? "{$data['publishDays']}天前发布" : '今天发布'; $data['createTime'] = date('Y-m-d H:i:s', $contentBasic['created']); $data['updateTime'] = date('Y-m-d H:i:s', $contentBasic['updated']); //增加委托房源标签 $isEntrust = Bll_Zufang_Choice::isCommissionHouse($propId, $brokerId, Model_House_Commission::TYPE_RENT); if ($isEntrust) { $data['isEntrust'] = 1; } else { $data['isEntrust'] = 0; } return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => $data); }
/** * 页面数据预加载模块 */ public function beforePost() { // 初始化页面变量 $this->ctx = Bll_House_HzPublish::initPageVariables($this->ctx); if ($this->ctx['proId']) { $propInfo = Bll_House_HzHouse::getPropInfo($this->ctx['proId'], $this->ctx['cityId']); // 房源不存在 if (!$propInfo['status']) { $this->redirect2Result(Const_PublishCode::HOUSE_NOT_EXIST, $this->site, $this->action, $this->ctx['proId']); } $tmpProId = $this->ctx['proId']; if ($propInfo['status']) { $this->ctx = array_merge($this->ctx, $propInfo['msg']); } // fix 大json里proid存成0的问题 if (!$this->ctx['proId']) { $this->ctx['proId'] = $tmpProId; } // 非自己房子 if ($propInfo['msg']['userid'] != $this->ctx['hzBrokerId']) { $this->redirect2Result(Const_PublishCode::NOT_OWN_HOUSE, $this->site, $this->action, $this->ctx['proId']); } } // 区域 $this->ctx['areaArr'] = Model_City_HzArea::getAreasByCityId($this->ctx['cityId']); // 板块 $this->ctx['blockArr'] = Model_City_HzArea::getBlockByAreaId($this->ctx['areaid']); // 房屋类型 $this->ctx['propTypeArr'] = Bll_House_HzHouse::getPropType($this->ctx['cityId']); // 装修类型 $this->ctx['fitmentArr'] = Bll_House_HzHouse::getFitment($this->ctx['cityId']); // 朝向 $this->ctx['towardArr'] = Bll_House_HzHouse::getToward(); // 房屋配置 $this->ctx['deploymentArr'] = Bll_House_HzHouse::getDeployment(); // 付款类型 $this->ctx['payTypeArr'] = Bll_House_HzHouse::getRentDepositAndCycle($this->ctx['cityId']); // 合租类型 $this->ctx['shareType'] = Bll_House_HzHouse::getShareType(); // 合租性别 $this->ctx['shareSexArr'] = Bll_House_HzHouse::getShareSex(); // 检查低价城市 $this->ctx['checkLowPriceCity'] = Bll_House_HzHouse::getCheckLowPriceCity(); // 获取图片 $this->ctx['images'] = Bll_Image_HzHouseImage::getImagesByHouseIds($this->ctx['proId'], true); $this->ctx['picData'] = Bll_House_HzPublish::buildImagesForPage($this->ctx['images']); $this->ctx['isShowCommPic'] = in_array($this->ctx['cityId'], array(11)) ? 0 : 1; $this->ctx['publishHouseProtocolUrl'] = Bll_House_EsfPublish::getPublishHouseProtocolUrl($this->ctx['cityId']); // 房源是否可以推广信息 $this->ctx = Bll_House_HzPublish::getSpreadFlagInfo($this->ctx); // 获取图片服务器host $this->ctx['picUploadServerDomain'] = Bll_Image_HzHouseImage::getPicUpdServerDomain(); if ($this->ctx['isEdit']) { $this->action = 'edit'; } // inject $this->ctx = Bll_House_HzPublish::beforePostInjectAfter($this->ctx); // debug $this->ctx['debug'] == 'all' && (print_r($this->ctx) && die); if (isset($this->ctx['file'])) { unset($this->ctx['file']); } return $this->ctx; }
/** * 精选房源设置页面 * * @param int $ajk_broker_id * @param int $city_id * @param int $prop_id * @param array $params * * @return array */ public static function hz_setting($ajk_broker_id, $city_id, $prop_id, $params = array()) { $pageAttribute = array('broker_id' => $ajk_broker_id, 'prop_id' => $prop_id); //获取精选推广预算 $brokerInfo = Bll_BrokerBaseBll::get_instance()->get_broker_info($ajk_broker_id); $brokerCompanyId = $brokerInfo['BaseInfo']['COMPANYID']; $choiceSet = APF::get_instance()->get_config('choice_set'); if (isset($choiceSet[$brokerCompanyId]) && !empty($choiceSet[$brokerCompanyId])) { $pageAttribute['min_budget'] = $choiceSet[$brokerCompanyId]['hz']['HZ_CHOICE_MIN_BUDGET']; $pageAttribute['max_budget'] = $choiceSet[$brokerCompanyId]['hz']['HZ_CHOICE_MAX_BUDGET']; } else { $pageAttribute['min_budget'] = $choiceSet['default']['hz']['HZ_CHOICE_MIN_BUDGET']; $pageAttribute['max_budget'] = $choiceSet['default']['hz']['HZ_CHOICE_MAX_BUDGET']; } $hz_broker_id = Model_Broker_HzMapping::get_hz_broker_id($ajk_broker_id); if (0 == $hz_broker_id) { return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '您不是好租经纪人'); } /** 经纪人重新推广房源 */ if (isset($params['act']) && $params['act'] == 'rebid') { $planInfo = Model_Plan_HzPlanBasic::get_plan_by_id($params['plan_id']); if ($planInfo['plan_type'] != 2 || $planInfo['bid_version'] != 2) { return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '房源所在的计划不是精选房源计划'); } if ($planInfo['status'] == Const_HzPlan::WAITING || $planInfo['status'] == Const_HzPlan::SPREAD) { return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '房源已经精选'); } $pageAttribute['plan_id'] = $params['plan_id']; $pageAttribute['rebid'] = true; } else { $propPlan = Model_Plan_HzPlanning::getPropBidPlan($prop_id); if (!empty($propPlan)) { $planInfo = Model_Plan_HzPlanBasic::get_plan_by_id($propPlan['plan_id']); if ($planInfo['bid_version'] == Const_HzPlan::BID_VERSION_CHOICE && ($planInfo['status'] == Const_HzPlan::WAITING || $planInfo['status'] == Const_HzPlan::SPREAD)) { return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '房源已经精选'); } if ($planInfo['bid_version'] == Const_HzPlan::BID_VERSION_CHOICE && $propPlan['is_valid'] != 0 && $planInfo['status'] != Const_HzPlan::DELETE && $planInfo['flag'] == 1) { $pageAttribute['plan_id'] = $propPlan['plan_id']; $pageAttribute['rebid'] = true; } else { /** 检查 经纪人是不是 已经满足10套 */ $onlinePlanCount = Model_Plan_HzPlanBasic::count_online_bid_plan_ex($ajk_broker_id); if ($onlinePlanCount >= self::ALL_ZF_PLAN_NUM) { return array('err_no' => Bll_Plan_Bid_Choice::BID_FAIL_OTHER, 'err_msg' => '您最多可以对' . self::ALL_ZF_PLAN_NUM . '套房源做精选推广,请确认数量是否已经达到上限'); } } } } /** 获取房源基本信息 */ $propInfo = Model_House_HzProp::get_prop_info_by_prop_id($prop_id); if (empty($propInfo)) { return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '房源不存在(code:-3)'); } if (empty($propInfo['contentBasic']) || !isset($propInfo['contentBasic']['userid']) || $propInfo['contentBasic']['userid'] != $hz_broker_id) { return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '房源不存在(code:-2)'); } if (false == $propInfo['contentBasic']['quality']) { return array('err_no' => self::BID_FAIL_QUALITY_OR_NEW, 'err_msg' => '多图、新发15天房源才能参与精选推广'); } if (date('Ymd', strtotime('-15 days')) > date('Ymd', $propInfo['contentBasic']['created'])) { return array('err_no' => self::BID_FAIL_QUALITY_OR_NEW, 'err_msg' => '多图、新发15天房源才能参与精选推广'); } /** 判断是否是精选开放城市 */ if (!Bll_City::isChoiceIndependentCity($city_id, Const_Site::HAOZU)) { /** 判断房源是否在套餐推广 */ $propCombos = Bll_Combo_HouseRelation::getOnlineRelationByHouseId($prop_id, Bll_Combo_HouseRelation::SITE_TYPE_HZ); if (empty($propCombos)) { return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '房源必须在套餐推广才能参与精选'); } } $balance = self::get_broker_balance_by_broker_id($ajk_broker_id); $pageAttribute['balance'] = $balance; if ($balance > 0) { $balance = sprintf('%.2f', $balance / 100); } $pageAttribute['balance_fmt'] = $balance; /** * renttype: 1整租 2合租 */ if (empty($propInfo['contentBasic'])) { return array('err_no' => self::BID_FAIL_QUALITY_OR_NEW, 'err_msg' => '房源不存在(code:-4)'); } /** 出租方式 */ $rent_type = $propInfo['contentBasic']['renttype'] == 1 ? '整租' : '合租'; /** 房屋类型 */ $house_type_config = APF::get_instance()->get_config('housetype', 'house'); $house_type = isset($house_type_config[$city_id]) ? $house_type_config[$city_id] : $house_type_config[0]; $prop_type = isset($house_type[$propInfo['contentBasic']['protype']]) ? $house_type[$propInfo['contentBasic']['protype']] : '其他'; /** 户型 */ $room_amount = $propInfo['contentBasic']['roomnum']; $hall_amount = $propInfo['contentBasic']['hallnum']; $toilet_amount = $propInfo['contentBasic']['toilnetnum']; /** 出租面积 */ $area_amount = $propInfo['contentBasic']['areanum']; /** 租金 */ $price = $propInfo['contentBasic']['pricenum']; $title = $propInfo['contentBasic']['commname']; $blockInfo = Model_City_HzArea::getAreaById($propInfo['contentBasic']['blockid']); if (empty($blockInfo)) { $blockName = $title; } else { $blockName = $blockInfo['typeName']; } $pageAttribute['community_name'] = $blockName; /** 设置标题 */ $pageAttribute['title'] = sprintf('%s,%d室%d厅%d卫,%d平,%s,%s,%d元/月', $title, $room_amount, $hall_amount, $toilet_amount, $area_amount, $rent_type, $prop_type, $price); $bucketInfo = Bll_Choice_HzBidBucket::get_bucket_info($propInfo['contentBasic']['blockid'], $city_id, $propInfo['contentBasic']['pricenum']); $pageAttribute['bucket_total'] = $bucketInfo['totalNum']; $pageAttribute['bucket_used'] = $bucketInfo['usedNum']; // 取出area的areacode 取查询 (由于dw存的blockid是areacode) $area = Model_City_HzArea::getAreaById($propInfo['contentBasic']['blockid']); $averageClickAndBudget = Bll_Choice_HzBidBucket::getBucketAverageClickBudget($area['typeCode'], $city_id, $propInfo['contentBasic']['pricenum']); if (!empty($averageClickAndBudget)) { $pageAttribute['averageClick'] = $averageClickAndBudget['averageClick']; $pageAttribute['averageBudget'] = $averageClickAndBudget['averageBudget'] / 100; } /** 获取点击单价 */ try { $clickPrice = Bll_Service_Choice::hzClickPrice(array('brokerId' => $ajk_broker_id, 'cityId' => $city_id, 'price' => (int) $propInfo['contentBasic']['pricenum'], 'blockId' => $propInfo['contentBasic']['blockid'])); if ($clickPrice['status'] == 'error') { return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '系统繁忙(code:-1)'); } } catch (Exception $e) { return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '系统繁忙(code:-33)'); } 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'] = isset($clickPrice['rebateEndTime']) ? $clickPrice['rebateEndTime'] : ''; } else { $pageAttribute['favorable'] = false; $pageAttribute['price'] = round($clickPrice['realTradeAmount'] / 100, 2); } $pageAttribute['bucket_used_num'] = $bucketInfo['usedNum']; $pageAttribute['bucket_total_num'] = $bucketInfo['totalNum']; $pageAttribute['bucket_max_online_num'] = $bucketInfo['maxOnlineNum']; $pageAttribute['hidden']['show'] = $bucketInfo['maxOnlineNum'] > $bucketInfo['usedNum'] ? 1 : 0; $priceInfo = Model_House_HzPriceChoice::get_price_by_id($bucketInfo['priceId']); if (($pos = strpos('以', $priceInfo['title'])) !== false) { $priceInfo['title'] = substr($priceInfo['title'], 0, $pos) . '元' . substr($priceInfo['title'], $pos); } else { $priceInfo['title'] = $priceInfo['title'] . '元'; } $pageAttribute['price_title'] = $priceInfo['title']; return $pageAttribute; }
/** * 根据板块id获取精选房源,写房源日志 * * @param int $brokerId * @param $oldAreaCode * @param $newAreaCode * @return array */ public static function hzCommunityAreaChangeEx($brokerId, $oldAreaCode, $newAreaCode) { $newAreaInfo = Model_City_HzArea::getAreaByTypeCode($newAreaCode); $oldAreaInfo = Model_City_HzArea::getAreaByTypeCode($oldAreaCode); if (empty($newAreaInfo)) { return static::buildReturn(self::PROCESS_STATUS_ERROR, '好租区域板块变更,新的板块Id[' . $newAreaCode . ']映射不存在'); } if (empty($oldAreaInfo)) { return static::buildReturn(self::PROCESS_STATUS_ERROR, '好租区域板块变更,旧的板块Id[' . $oldAreaCode . ']映射不存在'); } $choicePlanList = Model_Plan_HzPlanBasic::getChoicePlanByBlockId($oldAreaInfo['cityId'], $oldAreaInfo['id']); if (empty($choicePlanList)) { return static::buildReturn(self::PROCESS_STATUS_SUCCESS, '好租区域板块变更,旧的板块Id[' . $newAreaCode . '],没有精选计划'); } $choicePlanIdList = array(); foreach ($choicePlanList as $choicePlanInfo) { $choicePlanIdList[] = $choicePlanInfo['id']; } $choicePlaningList = Model_Plan_HzPlanning::getPlanningByPlanIds($choicePlanIdList); if (empty($choicePlaningList)) { return static::buildReturn(self::PROCESS_STATUS_ERROR, sprintf('好租区域板块变更,没有获取到精选[%s]计划房源关系信息', implode(',', $choicePlanIdList))); } /** 写房源日志 */ $remark = json_encode(array('remark' => '区域板块变更', 'newAreaCode' => $newAreaCode, 'oldAreaCode' => $oldAreaCode, 'newBlockId' => $newAreaInfo['id'], 'oldBlockId' => $oldAreaInfo['id'])); $rtn = array(); foreach ($choicePlaningList as $choicePlaningInfo) { $houseLog = array(); $houseLog['houseId'] = $choicePlaningInfo['proid']; $houseLog['planId'] = 0; $houseLog['brokerId'] = $brokerId; $houseLog['cityId'] = $choicePlaningInfo['city_id']; $houseLog['type'] = Model_Log_HouseLogNew::TYPE_COMMUNITY_AREA_CHANGE_EX; $houseLog['changeType'] = Const_ProPlanChangeType::COMMUNITY_AREA_CHANGE_EX; $houseLog['remark'] = $remark; $houseLog['addDate'] = date('Y-m-d H:i:s'); $houseLog['operatorId'] = 0; $houseLog['siteType'] = 2; if (!Model_Log_HouseLogNew::create($houseLog, date('Ymd'))->save()) { $rtn[] = sprintf('板块变更房源[%d]日志写入失败', $choicePlaningInfo['proid']); continue; } $rtn[] = sprintf('板块变更房源[%d]日志写入成功', $choicePlaningInfo['proid']); } return static::buildReturn(self::PROCESS_STATUS_SUCCESS, sprintf('好租区域板块变更,%s', implode(',', $rtn))); }
private static function preparePropInfo(&$out) { // 获取房源 $propResult = Bll_House_HzHouse::getPropInfo($out['proId'], $out['cityId'], 3); if (!$propResult['status']) { throw new Exception($propResult['msg']); } $propInfo = $propResult['msg']; // 检查并拼接违规信息 $illegalInfo = Bll_HzProp::checkAndGetPropsIllegalInfos(array($out['proId'] => $propInfo)); $propInfo = $illegalInfo[$out['proId']]; // 获取剩余时间 $propInfo['leftDays'] = Bll_House_HzHouse::getLeftDays($propInfo['created']); // 获取房源图片数 $imageInfo = Bll_House_HzHouse::getPropImages($out['proId']); $propInfo['imageInfo'] = $imageInfo; // 房源默认图片 (默认优先封面图 -》 第一张室内图 -》 房型) //$propInfo['propDefaultImg'] = Bll_House_HzHouse::getPropDefaultImgWithUrl($out['proId']); $propInfo['propDefaultImg'] = self::getThumbImg($imageInfo); // 获取房源可优化项 $propInfo['canImproveItems'] = self::getPropCanImproveItems($propInfo, $imageInfo); // 是否手机发房 $propInfo['isMobile'] = isset($propInfo['from']) ? Bll_House_HzHouse::isMobileProp($propInfo['from']) : false; // 此房源全部点击数据 $propInfo['propAllClick'] = Model_Stats_PropClick::getPropAllClicks($out['proId'], $out['hzBrokerId'], $out['cityId']); // 此房源全部曝光数据 $propInfo['propAllShow'] = Bll_House_HzHouse::getPropShow($out['proId'], $out['cityId']); // 此房源质量 $propQuality = Model_Stats_HzPropQuality::getPropsquality($out['proId']); $propInfo['propsQuality'] = $propQuality ? $propQuality[$out['proId']] : array(); // 根据blockid 获取对应code $areaInfo = Model_City_HzArea::getAreaById($propInfo['blockid']); $propInfo['typeCode'] = $areaInfo['typeCode']; return $propInfo; }
/** * @param $cityId * @param $areaId * @return array|mixed|null */ public static function getBlocks($cityId, $areaId) { return Model_City_HzArea::getBlocksByAreaId($cityId, $areaId); }