/** * @param $brokerId * @param $propId * @return bool * 添加房源推广位提醒 */ public function startChoiceSubscription($brokerId, $propId) { //获取经纪人基本信息 $brokerBaseInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId); if (empty($brokerBaseInfo)) { $this->error(self::EMPTY_BROKER_ERROR, self::EMPTY_BROKER_ERROR_MSG); } //判断经纪人城市是否开通精选 $cityId = $brokerBaseInfo->cityId; if (!$this->checkChoiceOpen($cityId)) { $this->error(self::CHOICE_CLOSE_ERROR, self::CHOICE_CLOSE_ERROR_MSG); } //判断房源是否存在 $houseInfo = Bll_House_EsfHouse::getHouseBaseInfo($propId, $cityId); if (empty($houseInfo)) { $this->error(self::PROP_NOT_EXIST_ERROR, self::PROP_NOT_EXIST_ERROR_MSG); } //判断房源是否属于当前经纪人 $userId = $brokerBaseInfo->userId; $houseInfo = $houseInfo[0]; if ($houseInfo->userId != $userId) { $this->error(self::PROP_OPREATE_ACCESS_INVALID_ERROR, self::PROP_OPREATE_ACCESS_INVALID_ERROR_MSG); } //判断房源是否违规 if ($houseInfo->isVisible != 1) { $this->error(self::PROP_CHOICE_NOT_FIT_ISVISIBLE_ERROR, self::PROP_CHOICE_NOT_FIT_ISVISIBLE_ERROR_MSG); } //判断房源是否多图 if ($houseInfo->isHighQulity == 0) { $this->error(self::PROP_CHOICE_NOT_FIT_ISHIGHQULITY_ERROR, self::PROP_CHOICE_NOT_FIT_ISHIGHQULITY_ERROR_MSG); } //判断房源是否新发15天 if (date('Ymd', strtotime('-16 days')) > date('Ymd', $houseInfo->postDate)) { $this->error(self::PROP_CHOICE_NOT_FIT_POSTDATE_ERROR, self::PROP_CHOICE_NOT_FIT_POSTDATE_ERROR_MSG); } //获取房源价格段 $housePrice = intval($houseInfo->proPrice * 10000); $priceIntervalInfo = Model_House_EsfPrice::get_price($cityId, $housePrice); if (empty($priceIntervalInfo)) { $this->error(self::PROP_PRICE_UNKNOW_ERROR, self::PROP_PRICE_UNKNOW_ERROR_MSG); } $priceId = $priceIntervalInfo['id']; //根据房源所在CommId和PriceId获取坑位信息 $bucketInfo = Model_Choice_EsfBidBucket::get_bucket_info($houseInfo->commId, $priceId); if ($bucketInfo['usedNum'] < $bucketInfo['totalNum']) { $this->error(__LINE__, '推广位未满'); } //套餐经纪人 还是ppc经纪人 /*$IsComboBroker = Bll_Broker_HzBroker::isComboBroker($brokerId); if ($IsComboBroker) { //是否套餐推广 $comboHouseRelation = Model_Combo_HouseRelation::getOnlineHousebyHouseId($brokerId, $propId, $cityId, Model_Combo_HouseRelation::SITE_TYPE_AJK); if(empty($comboHouseRelation)) { $this->error(self::PROP_NO_COMBO, self::PROP_NO_COMBO_MSG); } } else { //PPC经纪人 判定定价关系 $fixPlanBll = new Bll_FixedSpread_PropFixedPlanRelation(); $fixPlanRelationStatus = $fixPlanBll->getProSpreadRelationByProId($propId, $cityId); if ($fixPlanRelationStatus['Status'] != 1) { $this->error(self::PROP_CHOICE_NOT_FIT_FIXED_ERROR, self::PROP_CHOICE_NOT_FIT_FIXED_ERROR_MSG); } }*/ /** 判断是否是精选开放城市 */ if (!Bll_City::isChoiceIndependentCity($cityId, Const_Site::ANJUKE)) { //是否套餐推广 $comboHouseRelation = Model_Combo_HouseRelation::getOnlineHousebyHouseId($brokerId, $propId, $cityId, Model_Combo_HouseRelation::SITE_TYPE_AJK); if (empty($comboHouseRelation)) { $this->error(self::PROP_NO_COMBO, self::PROP_NO_COMBO_MSG); } } $bucketId = $bucketInfo['id']; $subscriptionInfo = Model_Choice_Subscription::selectData(array(Model_Choice_Subscription::SITE => Model_Choice_Subscription::SITE_AJK, Model_Choice_Subscription::BROKER_ID => $brokerId, Model_Choice_Subscription::PROP_ID => $propId, Model_Choice_Subscription::BUCKET_ID => $bucketId), array(), 'find_only'); if (empty($subscriptionInfo)) { $result = Model_Choice_Subscription::initData(Model_Choice_Subscription::SITE_AJK, $brokerId, $propId, $bucketId, Model_Choice_Subscription::SUBSCRIPTION_START); } else { if ($subscriptionInfo['status'] == Model_Choice_Subscription::SUBSCRIPTION_START) { $this->error(__LINE__, '推广位已订阅'); } else { $subscriptionInfo['status'] = Model_Choice_Subscription::SUBSCRIPTION_START; $result = $subscriptionInfo->save(); } } return $result; }
/** * @param $request object * @param $brokerInfo array * @param $type string rent || sale * @return array */ public static function getShopBeforePost($request, $brokerInfo, $type) { $out = $logGiveArr = array(); $params = $request->get_parameters(); // manager_id不为空,说明是伪登录 $out['managerId'] = $request->get_cookie('manager_id'); // 经纪人信息 $out['brokerInfo'] = $brokerInfo; $cityId = $brokerInfo['CITYID']; //金铺城市ID转换 $jpCityId = $out['brokerInfo']['jpCityId'] = BLL_House_JpHouseManage::getMemberCityId($cityId); $out['ajkBrokerId'] = $out['brokerInfo']['BROKERID']; $jpMember = Model_Broker_JpBroker::getJpBrokerInfoByAjkBrokerId($out['ajkBrokerId']); $out['brokerInfo']['jpMemberId'] = intval($jpMember->id); //获取城市配置信息是否是精选推广 $out['isChoiceCity'] = Bll_City::isChoiceCity($jpCityId, Const_Site::JINPU); $out['bidTip'] = $out['isChoiceCity'] ? '精选' : '竞价'; //是否套餐经纪人 $out['isCombo'] = $brokerInfo['PAYTYPE'] == 9999 ? 1 : 0; //套餐城市是否显示推广按钮,以及提示 $out['spreadFlagInfo'] = array('spreadFlag' => 1, 'info' => ''); if ($out['isCombo']) { $comboCheck = Bll_Combo_HouseRelation::housePublishComboCheck($out['ajkBrokerId'], $cityId, Bll_Combo_HouseRelation::SITE_TYPE_JP); if ($comboCheck['status'] != 1) { $out['spreadFlagInfo'] = array('spreadFlag' => 0, 'info' => $comboCheck['msg']); } } // 获取全部图片分类信息(用于编辑时候默认展示分类情况) $arrCategory = array(); $arrAllCates = Model_Image_Category::get_img_cates_by_type('shop'); $arrCategory['all'] = $arrAllCates; $arrCategory['classify'] = array_fill_keys(array_keys($arrAllCates), 0); $out['arrCategory'] = $arrCategory; // 描述引导 $out['descGuide'] = self::getShopDescGuideTitle($type); //编辑图片,用于展示退回照片模块 $out['editPic'] = $params['edit_pic']; //北上广深 四城市 $citySpecial = array('13', '14'); $out['priceType'] = in_array($jpCityId, $citySpecial) ? 1 : 0; $out['isPost'] = $request->is_post_method(); if ($type == 'rent') { //交租方式 $out['rentModeFirst'] = Model_House_JpShopRent::getRentModeFirst(); $out['rentModeSecond'] = Model_House_JpShopRent::getRentModeSecond(); } //---------是否编辑---------------// $shopInfo = array(); $shopId = 0; $propertyId = 0; // 初始化参数 $matches = $request->get_router_matches(); if (isset($matches[2]) && !empty($matches[2])) { $shopId = intval($matches[2]); $shopInfo = $type == 'rent' ? Model_House_JpShopRent::getPropInfoById($shopId) : Model_House_JpShopSale::getPropInfoById($shopId); $propertyId = $shopInfo['propertyId']; } $out['isEdit'] = empty($shopInfo) ? 0 : 1; //四选一弹层 $out['bolFlag'] = $out['isEdit'] || !isset($params['from']) ? 0 : 1; $out['shopInfo'] = $shopInfo; $out['shopId'] = $shopId; if (!$out['isCombo']) { $planInfo = BLL_House_JpHouseManage::getFixPlanInfo($shopId); if ($out['isEdit'] && $planInfo['success'] && $planInfo['data']['status'] == 3) { //定价计划状态为3,不可编辑 return array('status' => 'error', 'errCode' => Const_PublishCode::UNKNOWN_ERROR); } } //新发,需要验证房源发布套数限制 if (!$out['isEdit']) { if (BLL_House_JpHouseManage::houseNumLimit($out['brokerInfo']['jpMemberId'], $out['ajkBrokerId'], true)) { //保存漏斗日志 if ($out['isPost']) { $houseType = Bll_Loudou_Log::jinpuHouseType('shop', $type); $str = ''; switch ($params['goto_next_step']) { case 'planCombo': case 'planFix': $str = Bll_Loudou_Log::RESULT_TYPE_FIX_FAILED_OTHERS; break; case 'justSaveHouse': $str = Bll_Loudou_Log::RESULT_TYPE_SAVE_FAILED_HOUSE_MAX_LIMIT; break; } $logGiveArr[] = array('func' => array('Bll_Loudou_log', 'add'), 'params' => array($houseType, $str, Bll_Loudou_Log::SOURCE_TYPE_FORM)); } return array('status' => 'error', 'errCode' => Const_PublishCode::PUBLISH_OUT_OF_LIMIT); } } //经营信息模块的配置信息 list($out['enumShopType'], $out['enumShopMatching'], $out['enumShopIndustry'], $out['enumShopIndustryLimit'], $out['enumShopPassengerType']) = BLL_House_JpProperty::getShopEnum(); //页面精品房源url $out['exquisiteUrl'] = BLL_Plan_JpPlanUrl::buildHelpUrl('1026'); //页面经典范例url $out['exampleTitleUrl'] = BLL_Plan_JpPlanUrl::buildHelpUrl('1044'); //页面房源描述下方经典范例url $out['exampleDescUrl'] = BLL_Plan_JpPlanUrl::buildHelpUrl('1045'); //房源发布协议url $out['contractUrl'] = BLL_Plan_JpPlanUrl::buildHelpUrl('554'); //房源PPC价格段信息 $out['ppcInfo'] = Bll_Plan_JpPlanManage::getInstance()->getPPCPrice($jpCityId, $type == 'rent' ? 3 : 4); //城市区域列表,选择区域使用 $out['districts'] = Model_Jinpu_District::getCityDistricts($jpCityId); //经纪人定价推广组信息 $out['fixPlanInfo'] = $out['isCombo'] ? array() : Bll_Plan_JpPlanManage::getInstance()->getBrokerFixPlans($out['brokerInfo']['jpMemberId']); if ($out['isEdit']) { //编辑状态下的特殊信息 //编辑 验证房源是否属于经纪人 if ($out['brokerInfo']['jpMemberId'] != $out['shopInfo']['memberId']) { return array('status' => 'error', 'errCode' => Const_PublishCode::NOT_OWN_HOUSE); } //房源交租方式(付一押一) list($out['rentModelFirst'], $out['rentModelSecond']) = explode(',', $shopInfo['rentMode']); //单层 多层 独栋 $out['floorType'] = 1; if ($shopInfo['isFullFloor']) { $out['floorType'] = 3; } elseif ($shopInfo['upFloor']) { $out['floorType'] = 2; } //房源推广信息,被编辑的房源是否在推广中 $houseCanSpread = 1; if ($out['isCombo']) { $houseCombo = Model_Combo_HouseRelation::getOnlineHousebyHouseId($out['ajkBrokerId'], $shopId, $cityId, Model_Combo_HouseRelation::SITE_TYPE_JP); if (!empty($houseCombo)) { $houseCanSpread = 0; } } else { $shopIdx = Model_House_JpHouseIdx::data_access()->filter('id', $shopId)->get_row(); if (!empty($shopIdx['fixSpreadId'])) { $houseCanSpread = 0; } } $out['houseCanSpread'] = $houseCanSpread; //图片退回信息 $out['backRows'] = array(); if ($shopId && $out['isEdit']) { $out['backRows'] = Bll_Image_JpHouseImage::getBackRows($shopId, $type == 'rent' ? 3 : 4); } //房源描述 $desc = $type == 'rent' ? Model_Jinpu_ShopRentDesc::getByPk($shopId) : Model_Jinpu_ShopSaleDesc::getByPk($shopId); $out['shopDesc'] = $desc['desc']; //房源物业信息 $out['propertyData'] = $propertyData = (array) BLL_House_JpProperty::getProperty($shopInfo['propertyId']); if (!$propertyData) { return array('status' => 'error', 'errCode' => Const_PublishCode::NOT_OWN_HOUSE); } if ($propertyData['isRoad'] == 1 && ($shopInfo['districtId'] || !$shopInfo['blockId'])) { $out['forceBlockEdit'] = true; } elseif ($propertyData['isRoad'] == 0 && (!$propertyData['districtId'] || !$propertyData['blockId'])) { $out['forceBlockEdit'] = true; } if (!$out['forceBlockEdit']) { //逻辑好多啊 妹子的 $districtIdForSearch = !$propertyData['isRoad'] ? $propertyData['districtId'] : $shopInfo['districtId']; $blockIdForSearch = !$propertyData['isRoad'] ? $propertyData['blockId'] : $shopInfo['blockId']; $districtInfo = Model_Jinpu_District::data_access()->filter('id', $districtIdForSearch)->get_row(); $districtName = $districtInfo['is_actived'] == 1 ? $districtInfo['name'] : ''; $blockInfo = Model_Jinpu_Block::data_access()->filter('id', $blockIdForSearch)->get_row(); $blockName = $blockInfo['isActived'] == 1 ? $blockInfo['name'] : ''; $titleStr = $districtName . ' ' . $blockName . ' ' . (!$propertyData['isRoad'] ? $propertyData['address'] : '') . (!empty($shopInfo['closeRoad']) ? '靠近:' . $shopInfo['closeRoad'] : ''); $showStr = strlen($titleStr) > 90 ? Util_GlobalFunc::cutchar($titleStr, 28) : $titleStr; $out['titleStr'] = $titleStr; $out['showStr'] = $showStr; } $out['hasLibrary'] = BLL_House_JpProperty::hasLibrary($out['brokerInfo']['jpMemberId'], $shopInfo['propertyId'], 'property'); //房源图片查询和排序 $images = self::handleShopImages($shopId, $type); //个人图库图片是否被锁定 foreach ($images as $key => $imgVal) { $imgVal['isLock'] = 0; if ($imgVal && $imgVal['personalImgId']) { $personalImg = Model_Jinpu_PersonalGallery::getImgById($imgVal['personalImgId']); if ($personalImg && $personalImg->category) { $imgVal['isLock'] = 1; } } if ($imgVal['category'] && isset($out['arrCategory']['classify'][intval($imgVal['category'])])) { $out['arrCategory']['classify'][intval($imgVal['category'])] += 1; } $images[$key] = $imgVal; } $out['images'] = $images; } $lng = $lat = $mapDataFlag = 0; //地图标注商铺位置的逻辑 $DShopMap = Model_Jinpu_MapShop::getByPK($shopId); if (!empty($DShopMap)) { $lng = $DShopMap['lng']; $lat = $DShopMap['lat']; $mapDataFlag = 1; } else { if ($propertyId > 0) { $shopLocation = Model_Jinpu_MapProperty::getPropertyMapById($propertyId); if (!empty($shopLocation)) { $lng = $shopLocation['lng']; $lat = $shopLocation['lat']; } } else { list($lng, $lat) = BLL_House_JpHouseManage::getDefaultMap($out['brokerInfo']['CITYID']); } $mapDataFlag = 0; } $out['lng'] = $lng; $out['lat'] = $lat; $out['mapDataFlag'] = $mapDataFlag; return array('status' => 'ok', 'info' => $out, 'logArr' => $logGiveArr); }
/** * 判断经纪人是否可以添加房源精选订阅 * * 1. 是否已精选房源 * 2. 是否已设提醒房源 * 3. 是否具有精选资格房源:定价,多图,新发15天 * 4. 是否推广位已满 */ protected function hasAddChoiceRemindPermission() { // 是否已精选 $bllChoice = new Bll_Zufang_Choice(); $planInfo = $bllChoice->get_plan_by_proid($this->propId); if (!empty($planInfo)) { $planId = $planInfo->plan_id; $basicPlanInfo = $bllChoice->get_plan($planId); if ($basicPlanInfo[0]->status == 1 || $basicPlanInfo[0]->status == 13) { return array('code' => '', 'msg' => '房源已精选'); } } // 是否已订阅 $subscription = Model_Choice_Subscription::data_access()->filter('site', Model_Choice_Subscription::SITE_RENT)->filter('propId', $this->propId)->filter('bucketId', $this->bucket['id'])->find_only(); if ($subscription && $subscription['status'] == Model_Choice_Subscription::SUBSCRIPTION_START) { return array('code' => '', 'msg' => '推广位已订阅'); } // 是否可精选 // - 是否已定价/套餐 // - 是否多图 // - 是否新发15天 //套餐经纪人 还是ppc经纪人 /*$IsComboBroker = Bll_Broker_HzBroker::isComboBroker($this->brokerId); if ($IsComboBroker) { //是否套餐推广 $comboHouseRelation = Model_Combo_HouseRelation::getOnlineHousebyHouseId($this->brokerId, $this->propId, $this->broker['cityId'], Model_Combo_HouseRelation::SITE_TYPE_HZ); if(empty($comboHouseRelation)) { return array( 'code' => '', // TODO 'msg' => '不满足精选推广添加:套餐推广', ); } } else { //PPC经纪人 判定定价计划 $fixPlan = $this->prop->getFixPlan(); if(empty($fixPlan)) { return array( 'code' => '', // TODO 'msg' => '不满足精选推广添加:定价推广', ); } }*/ if (!Bll_City::isChoiceIndependentCity($this->broker['cityId'], Const_Site::ANJUKE)) { //是否套餐推广 $comboHouseRelation = Model_Combo_HouseRelation::getOnlineHousebyHouseId($this->brokerId, $this->propId, $this->broker['cityId'], Model_Combo_HouseRelation::SITE_TYPE_HZ); if (empty($comboHouseRelation)) { return array('code' => '', 'msg' => '不满足精选推广添加:套餐推广'); } } if (!($this->prop->isMultiImages() && $this->prop->getPublishedDays() <= 15)) { return array('code' => '', 'msg' => '不满足精选推广添加:多图,新发15天'); } // 是否推广位已满 if (!($this->bucket['usedNum'] >= $this->bucket['totalNum'])) { return array('code' => '', 'msg' => '推广位未满'); } return true; }