public function handle_request_internal() { $userId = $this->_params['userId']; $code = $this->_params['code']; //4.3之前版本的兼容性处理,此api之后将废弃 return array('status' => 'error', 'errcode' => Const_APIStatus::E_FYK_USER_ACTIVATION_CODE_CLOSE, 'message' => '此功能已关闭'); // TODO 校验用户是否存在 $brokerInfo = Model_Broker_AjkBrokerExtend::data_access()->filter('userId', $userId)->find_only(); if (!$brokerInfo) { throw new Exception_BrokerNotFoundException('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS); } // TODO 校验激活码是否有效 $codeInfo = Model_Fyk_InvitationCodes::data_access()->filter(Model_Fyk_InvitationCodes::CODE, $code)->filter(Model_Fyk_InvitationCodes::BIND_TO, $userId)->get_all(); if (empty($codeInfo)) { return API_Result::create()->error()->errorCode('9999')->message('邀请码错误')->toArray(); } $userInfo = Model_Fyk_Users::data_access()->filter(Model_Fyk_Users::USER_ID, $userId)->find_only(); if ($userInfo->status != Model_Fyk_Users::INIT) { return API_Result::create()->error()->errorCode('9999')->message('房源库功能已经激活')->toArray(); } $userInfo->status = Model_Fyk_Users::INVITATION; if ($userInfo->save()) { //TODO 关注房源库公共账号-待补充 $msg = '{"title": "房源库小喵 小贝欢迎大家到来","date": "' . date('m') . '月' . date('d') . '日","img":"http://pic1.ajkimg.com/m/fc68794e8da91a3d03f80487b888a193/540x270x95.jpg","desc": "成交从好的房源开始,好的房源来自移动房源库!","url": "http://api.anjuke.com/web/chat/content?id=101_290_0","jsonVersion": "1"}'; $chatInfo = Bll_Mobile_ChatInfoBll::getInstance()->getChatInfo($brokerInfo->brokerId, 1); $chatId = $chatInfo['data']['chatId']; Bll_Mobile_ChatInfoBll::sendFykPublicMsg($chatId, $msg); return array('status' => 'ok', 'message' => '激活成功'); } }
public function handle_request_internal() { $mobile = $this->_params['mobile']; $brokerInfo = Model_Broker_AjkBrokerExtend::data_access()->filter('userMobile', $mobile)->find_only(); if (!$brokerInfo) { return API_Result::create()->error()->errorCode('9999')->message('经纪人不存在')->toArray(); } $userId = $brokerInfo->userId; $userAccountId = Bll_Fyk_Payment_User::getInstance()->getUserAccountId($userId); if (empty($userAccountId)) { return API_Result::create()->error()->message('没有用户支付中心ID')->toArray(); } $time = date('Y-m-d H:i:s'); $data['userId'] = $brokerInfo->userId; $data['brokerId'] = $brokerInfo->brokerId; $data['cityId'] = $brokerInfo->cityId; $data['createTime'] = $time; $insertUserId = Model_Fyk_Users::getInstance()->insertData($data); unset($data); if ($insertUserId) { do { $code = rand(100000, 999999); $arr = Model_Fyk_InvitationCodes::data_access()->load_field('id')->filter('code', $code)->get_row(); } while ($arr !== NULL); $data['code'] = $code; //生成邀请码 $data['bindTo'] = $userId; $data['createTime'] = $time; $insertInvitationCodeId = Model_Fyk_InvitationCodes::getInstance()->insertData($data); if ($insertInvitationCodeId) { return API_Result::create()->ok()->data(array('status' => 1))->toArray(); } } }
public function handle_request_internal() { $brokerId = $this->_params['brokerId']; $wechatName = isset($this->_params['wechatName']) ? trim($this->_params['wechatName']) : ''; $introduce = trim($this->_params['introduce']); $shopImage = isset($this->_params['shopImage']) ? json_decode($this->_params['shopImage'], true) : array(); // 判断经纪人是否存在 $broker = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId); if (!$broker) { throw new Exception_Broker_NotFound('BrokerId: ' . $brokerId); } // 获取经纪人店铺 $shop = Model_Weshop_Shop::getBrokerShop($brokerId); // 更新店铺信息 if ($wechatName) { $shop->wechatName = $wechatName; } $shop->introduce = $introduce; if (isset($shopImage['host']) && isset($shopImage['hash'])) { $shop->imageHostId = intval($shopImage['host']); $shop->imageHash = $shopImage['hash']; } $shop->save(); // 拼装返回数据 $data = array('message' => '保存成功'); return API_Result::create()->ok()->data($data)->toArray(); }
public function handle_request_internal() { $brokerId = $this->_params['brokerId']; $type = $this->_params['type']; Bll_Broker_AppSwitch::off($brokerId, $type); return API_Result::create()->ok()->data(array('status' => 1))->toArray(); }
public function handle_request_internal() { $userId = $this->_params['userId']; // TODO 校验用户是否存在 $brokerInfo = Model_Broker_AjkBrokerExtend::data_access()->filter('userId', $userId)->find_only(); if (!$brokerInfo) { throw new Exception_BrokerNotFoundException('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS); } $data = self::getFykStatus(intval($userId), $brokerInfo['cityId']); return API_Result::create()->ok()->data($data)->toArray(); }
public function handle_request_internal() { $cityId = isset($this->_params['cityId']) ? $this->_params['cityId'] : 0; $data = array(); $filters = array(); $filtersConf = APF::get_instance()->get_config('prop_search_filters', 'fyk_search'); foreach ($filtersConf as $filterConf) { $filter = array('name' => $filterConf['name'], 'label' => $filterConf['label'], 'options' => array()); foreach ($filterConf['options'] as $filterConfOption) { $filter['options'][] = array('value' => $filterConfOption['value'], 'label' => $filterConfOption['label'], 'selected' => isset($filterConfOption['selected']) ? intval($filterConfOption['selected']) : 0); } $filters[] = $filter; } $data['filters'] = $filters; return API_Result::create()->ok()->data($data)->toArray(); }
public function handle_request_internal() { //4.3之前版本的兼容性处理,此api之后将废弃 header("Access-Control-Allow-Origin: *"); return array('status' => 'error', 'errcode' => Const_APIStatus::E_FYK_USER_ACTIVATION_CODE_CLOSE, 'message' => '此功能已关闭'); $userId = $this->_params['userId']; // TODO 校验用户是否存在 $brokerInfo = Model_Broker_AjkBrokerExtend::data_access()->filter('userId', $userId)->find_only(); if (!$brokerInfo) { throw new Exception_BrokerNotFoundException('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS); } $codeInfo = Model_Fyk_InvitationCodes::data_access()->filter(Model_Fyk_InvitationCodes::BIND_TO, $userId)->get_row(); if (empty($codeInfo)) { return API_Result::create()->error()->errorCode('9999')->message('邀请码错误')->toArray(); } return API_Result::create()->ok()->data(array('code' => $codeInfo['code']))->toArray(); }
public function handle_request_internal() { $keyword = $this->_params['keyword']; $cityId = $this->_params['cityId']; $communities = array(); // Solr 查询 $solr = APF_Search_SearchClient::instance('community35'); $response = $solr->setKeywords($keyword)->addEqualFilter('cityid', $cityId)->addWeightedSearchField('name', 4)->addWeightedSearchField('sub_area_string', 2)->addWeightedSearchField('area_string', 1)->setLimit(0, 20)->fetchResult(); // 拼装小区结果 if (isset($response['response']['numFound']) && $response['response']['numFound']) { foreach ($response['response']['docs'] as $doc) { $doc['areacode']; $communities[] = array('commId' => $doc['id'], 'commName' => $doc['name'], 'blockId' => $doc['areacode'], 'blockName' => $doc['sub_area_string'], 'districtId' => substr($doc['areacode'], 0, 8), 'districtName' => $doc['area_string'], 'cityId' => $doc['cityid']); } } $data = array('communities' => $communities); return API_Result::create()->ok()->data($data)->toArray(); }
public function handle_request_internal() { $userId = $this->_params['userId']; $mobile = $this->_params['mobile']; $status = $this->_params['status']; if (!$userId) { $brokerInfo = Model_Broker_AjkBrokerExtend::data_access()->filter('userMobile', $mobile)->find_only(); } else { $brokerInfo = Model_Broker_AjkBrokerExtend::data_access()->filter('userId', $userId)->find_only(); } if (!$brokerInfo) { throw new Exception_BrokerNotFoundException('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS); } $userId = $brokerInfo->userId; try { Model_Fyk_Users::data_access()->set_field(Model_Fyk_Users::STATUS, $status)->filter(Model_Fyk_Users::USER_ID, $userId)->update(); } catch (Exception $e) { return API_Result::create()->error()->errorCode('9999')->message('修改房源库权限失败')->toArray(); } return API_Result::create()->ok()->data(array('message' => '修改成功'))->toArray(); }
public function handle_request_internal(){ $mobile = $this->_params['mobile']; $price = $this->_params['price']; $brokerInfo = Model_Broker_AjkBrokerExtend::data_access() ->filter('userMobile', $mobile) ->find_only(); if (!$brokerInfo) { return API_Result::create()->error()->errorCode('9999')->message('经纪人不存在')->toArray(); } $userId = $brokerInfo->userId; $userAccountId = Bll_Fyk_Payment_User::getInstance()->getUserAccountId($userId); if (empty($userAccountId)) { return API_Result::create()->error()->message('没有用户支付中心ID')->toArray(); } $addArr = array( 'userId' => $userId, 'propId' => 0, 'price' => $price, 'requestId' => 0, 'actionMsg' => '', 'actionCode' => Const_Fyk::USER_RECHARGE_BY_SYSTEM, 'status' => Model_Fyk_MoneyActionQueue::STATUS_NODEAL, 'createTime' => time() ); $id = Model_Fyk_MoneyActionQueue::getInstance()->insertData($addArr); if($id){ return API_Result::create() ->ok() ->toArray(); } else { return API_Result::create() ->error() ->message('插入系统加钱队列失败') ->toArray(); } }
public function handle_request_internal() { header("Access-Control-Allow-Origin: *"); $brokerId = $this->_params['brokerId']; // 判断经纪人是否存在 $broker = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId); if (!$broker) { throw new Exception_Broker_NotFound('BrokerId: ' . $brokerId); } // 获取经纪人微信店铺 $shop = Model_Weshop_Shop::getBrokerShop($brokerId); // 拼装店铺信息 $data = array(); $data['previewUrl'] = $shop->getPreviewUrl(); $data['trueName'] = $broker->trueName; $data['wechatName'] = $shop->wechatName; $data['userMobile'] = $broker->userMobile; $data['userPhotoUrl'] = $broker->getUserPhotoUrl(); $data['introduce'] = $shop->getIntroduce(); $data['shopImage'] = array('url' => $shop->getImageUrl(), 'host' => $shop->imageHostId, 'hash' => $shop->imageHash); //是否点亮微信 修改微信时点亮 $data['isLighten'] = $shop->isLighten; return API_Result::create()->ok()->data($data)->toArray(); }
public function handle_request_internal() { $brokerId = $this->_params['brokerId']; return API_Result::create()->ok()->data(Bll_Broker_AppSwitch::all($brokerId))->toArray(); }
public function handle_request_internal() { $propLists = array(); $hasNextPage = 0; $userId = $this->_params['userId']; $sinceId = isset($this->_params['sinceId']) ? intval($this->_params['sinceId']) : 0; $per = isset($this->_params['per']) ? $this->_params['per'] : 20; $propIds = Model_Broker_FykPushProps::data_access()->load_field('propId')->filter('userId', $userId)->sort('id', 'desc')->limit($per + 1)->offset($sinceId)->get_all(); if (!empty($propIds)) { $hasNextPage = count($propIds) > $per ? 1 : 0; if ($hasNextPage) { array_pop($propIds); $sinceId = $sinceId + $per; } else { $sinceId = 0; } $propIds = self::getArrayColumn($propIds, 'propId'); $props = Model_Fyk_PropLibrary::data_access()->filter('id', array_unique($propIds))->get_all(); //获取小区、板块名称 start $commNames = $typeNames = array(); $commIds = self::getArrayColumn($props, 'commId'); /*$commInfos = Model_Community_AjkCommunity::data_access() ->filter('commId', $commIds) ->get_all();*/ $commInfos = Bll_Community_APIComm::getInstance()->getInfoById($commIds); foreach ($commInfos as $info) { $commNames[$info['comm_id']] = $info['name']; } //———————————————————————————————————————————————— $districtIds = self::getArrayColumn($props, 'areaId'); $blockIds = self::getArrayColumn($props, 'blockId'); $typeIds = array_merge($districtIds, $blockIds); $typeInfos = Model_City_TypeCode::data_access()->load_field('typeId')->load_field('typeName')->filter('typeId', $typeIds)->get_all(); foreach ($typeInfos as $info) { $typeNames[$info['typeId']] = $info['typeName']; } //获取小区、板块名称 end foreach ($props as $prop) { //计算发布时间 $publishDate = strtotime(date('Y-m-d', $prop['createTime'])); $nowDate = strtotime(date('Y-m-d', time())); $publishDays = intval(($nowDate - $publishDate) / 86400); $propId = $prop['id']; $propList['fPropId'] = $propId; $propList['isOnly'] = $prop['isOnly']; $propList['isReal'] = $prop['isReal']; $propList['certificate'] = $prop['certificate']; $propList['commId'] = $prop['commId']; $propList['commName'] = $commNames[$prop['commId']]; $propList['districtId'] = $prop['areaId']; $propList['districtName'] = $typeNames[$prop['areaId']]; $propList['blockId'] = $prop['blockId']; $propList['blockName'] = $typeNames[$prop['blockId']]; $propList['roomNum'] = $prop['cell']; $propList['hallNum'] = $prop['hall']; $propList['toiletNum'] = $prop['toilet']; $propList['area'] = $prop['acreage']; $propList['areaUnit'] = '平'; $propList['price'] = intval($prop['totalPrices']); $propList['priceUnit'] = '万'; $propList['publishDays'] = $publishDays; $propList['publishDaysMsg'] = $propList['publishDays'] > 0 ? "{$propList['publishDays']}天前发布" : '今天发布'; $propLists[$propId] = $propList; } } $propListFormat = array(); foreach ($propIds as $id) { $propListFormat[] = $propLists[$id]; } unset($propLists); //更新为0 Model_Fyk_PushPropsLatestCount::data_access()->set_field('count', 0)->filter('userId', $userId)->update(); $data['props'] = $propListFormat; $data['sinceId'] = $sinceId; $data['hasNextPage'] = $hasNextPage; return API_Result::create()->ok()->data($data)->toArray(); }
public function handle_request_internal() { $brokerId = isset($this->_params['brokerId']) ? $this->_params['brokerId'] : 0; $keyword = isset($this->_params['keyword']) ? $this->_params['keyword'] : ''; $commId = isset($this->_params['commId']) ? $this->_params['commId'] : 0; $cityId = isset($this->_params['cityId']) ? $this->_params['cityId'] : 0; $distance = isset($this->_params['distance']) ? $this->_params['distance'] : 0; $price = isset($this->_params['price']) ? $this->_params['price'] : 0; $rooms = isset($this->_params['rooms']) ? $this->_params['rooms'] : 0; $lat = isset($this->_params['lat']) ? floatval($this->_params['lat']) : 0; $lng = isset($this->_params['lng']) ? floatval($this->_params['lng']) : 0; $page = isset($this->_params['page']) ? $this->_params['page'] : 1; $per = isset($this->_params['per']) ? intval($this->_params['per']) : 20; $data = array(); $data['page'] = $page; $data['hasNextPage'] = 0; $filters = APF::get_instance()->get_config('prop_search_filters', 'fyk_search'); $props = array(); if ($cityId == 0) { $brokerInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId); $cityId = $brokerInfo['cityId']; } // Solr 查询 $solr = APF_Search_SearchClient::instance('fyk-prop'); // 在售 $solr->addEqualFilter('status', Const_Fyk::PROPSTATUS_SELLING); if ($cityId) { $solr->addEqualFilter('city_id', $cityId); } // 过滤关键词或小区 if ($commId) { $solr->addEqualFilter('comm_id', $commId); } elseif ($keyword) { $solr->setKeywords($keyword)->addWeightedSearchField('comm_name', 4)->addWeightedSearchField('block_name', 1)->addWeightedSearchField('district_name', 1); } // 距离 if ($distance && isset($filters['distance']['options'][$distance]) && $lat && $lng) { $filters['distance']['options'][$distance]['lat'] = (double) $lat; $filters['distance']['options'][$distance]['lng'] = (double) $lng; $this->filterBuilder($solr, $distance, $filters['distance']); } // 价钱 if ($price && isset($filters['price']['options'][$price])) { $this->filterBuilder($solr, $price, $filters['price']); } // 户型 if ($rooms && isset($filters['rooms']['options'][$rooms])) { $this->filterBuilder($solr, $rooms, $filters['rooms']); } // 分页 if ($page) { $start = ($page - 1) * $per; $solr->setLimit($start, $per); } // 排序 $solr->addFieldSort('onsell_time', true); $response = $solr->fetchResult(); if (isset($response['response']['numFound']) && $response['response']['numFound']) { // 判定下一页 if ($response['response']['numFound'] > $page * $per) { $data['hasNextPage'] = 1; } // 取房源 foreach ($response['response']['docs'] as $doc) { $prop = array('fPropId' => $doc['id'], 'isOnly' => intval($doc['is_only']), 'isReal' => intval($doc['is_real']), 'certificate' => intval($doc['is_certificate']), 'commId' => $doc['comm_id'], 'commName' => $doc['comm_name'], 'districtId' => $doc['district_id'], 'districtName' => $doc['district_name'], 'blockId' => $doc['block_id'], 'blockName' => $doc['block_name'], 'roomNum' => $doc['room_num'], 'hallNum' => $doc['hall_num'], 'toiletNum' => $doc['toilet_num'], 'area' => $doc['area_num'], 'areaUnit' => '平米', 'price' => intval($doc['price'] / 10000), 'priceUnit' => '万', 'distance' => '', 'distanceUnit' => 'm', 'publishDays' => 0, 'publishDaysMsg' => ''); // 距离 if ($distance && isset($filters['distance']['options'][$distance]) && $lat && $lng) { list($propLat, $propLng) = explode(',', $doc['comm_location']); $prop['distance'] = intval(Util_Map::distance($lat, $lng, $propLat, $propLng)); if ($prop['distance'] > $distance) { $prop['distance'] = $distance; } } // 在售时间 if ($doc['onsell_time']) { $prop['publishDays'] = intval((strtotime(date('Y-m-d 00:00:00')) - strtotime(date('Y-m-d 00:00:00', $doc['onsell_time']))) / 86400); if ($prop['publishDays'] == 0) { $prop['publishDaysMsg'] = '今日发布'; } elseif ($prop['publishDays'] == 1) { $prop['publishDaysMsg'] = '昨日发布'; } else { $prop['publishDaysMsg'] = "{$prop['publishDays']}日前发布"; } } $props[] = $prop; } } $data['props'] = $props; return API_Result::create()->ok()->data($data)->toArray(); }