您的位置:首页 > 编程语言 > PHP开发

phpwind 房产 数据来源经纪人数据 增加个人中介公司调用分类

2012-06-11 17:25 381 查看
phpwind 房产 数据来源经纪人数据 增加个人中介公司调用分类  如图下所示  台州住房网



个人调用继承原来功能不变。

增加中介公司类别功能如下

所有调用字段

agencyid#4

name#路桥名益房产中介事务所

address#路桥名益房产中介事务所

icon#agency/625edbec7e.png

bgimg#

mainbusiness#1

adminname#admin   -------------管理者

isopen#1

vieworder#0

phone#18605766633   

tel#18605766633         ------------phone 和tel 值相同都是调用管理者的联系方式

url#index.php?m=house&q=agency&agencyid=4

title#路桥名益房产中介事务所

image#/attachment/agency/625edbec7e.png   icon 图片地址

以上调用条件

isopen =1 

排序为 vieworder 升序

修改文件

house/lib/db/house_agencydb.class.php

step1

添加变量

第5行

var $_secondpostTableName = "pw_house_broker";

第26行 添加方法
/**
*
* 中介公司自定义查询
*/
function findAll_li($condition,$page, $perpage, $order){
$condition = $this->_checkAllowField($condition, $this->getStruct());
$_sql = 'SELECT ha.*,hb.phone,hb.tel FROM '.$this->_tableName.' ha left join '.$this->_secondpostTableName.' hb on hb.username=ha.adminname ';
$_sql.= $this->getStrSql($condition);
$order && $_sql.= " ORDER BY " . $order;
$page = intval($page);
$perpage = intval($perpage);
$page <= 0 && $page=1;
$_sql.= S::sqlLimit(($page-1)*$perpage, $perpage);
$query = $this->_db->query($_sql);
$result = array();
while ($rt = $this->_db->fetch_array($query)) {
$result[] =$rt;
}
return $result;
}

文件2
house/lib/service/houseagencyservice.class.php

line33添加新方法

/**
* 搜索中介公司
* @param array $param 搜索条件
* @param int $page 页面
* @param int $perPage 每页显示数
* @return array
*/
function findAgencys($condition = array(), $page=1, $perpage=20, $order="vieworder"){
$page = (int) $page;
$page < 1 && $page = 1;
$con = $this->_cookData($condition);
$result = $this->agencydb->findAll_li($con,intval($page), intval($perpage), $order);
foreach ($result as $key => $value) {
$result[$key] = $value;
}
$count = $this->agencydb->count($con);
return array(
$result,
$count
);
}

文件三
house/lib/source/brokersource.class.php

查找 getSourceData 方法 修改为如下

/**
* 获取提交的数据
* @param array $config
* @param int $num
* @return array $result
*/
function getSourceData($config, $num) {
$config = $this->_initConfig($config);
if($config['sorttype']=='broker'){
$_tmp = $this->_getData($config, $num);
$_tmp = $_tmp ? $_tmp : array();
$_userids = array();
foreach ($_tmp as $key => $value) {
$_tmp[$key] = $this->_cookData($value);
$_userids[$key] = $value['uid'];
}
$_info = $this->_getFacesAndOnline($_userids);
foreach ($_tmp as $key => $value) {
$value && $_info[$value['uid']] && $result[] = array_merge($value, $_info[$value['uid']]);
}
}else{
$result = $this->_getData($config, $num,$config['sorttype']);
$result = $result ? $result : array();
$_userids = array();
foreach ($result as $key => $value) {
$result[$key] = $this->_cookAgencyidData($value);
}
}
return $result;
}

查找getSourceConfig 方法 修改为如下
/**
* 选择项
* @return array
*/
function getSourceConfig() {
return array(
'sort' => array(
'name' => '排序方式',
'type' => 'select',
'value' => array(
'salenum' => '出售房数量',
'hirenum' => '出租房数量',
'lastsaletime' => '最近发布',
'createtime' => '开通时间'
)
),
'sorttype' => array(
'name' => '中介类型',
'type' => 'select',
'value' => array(
'broker' => '个人',
'agency' => '中介公司'
)
),
);
}

查找一下方法修改为如下
/**
* 处理传入的数据
* @param array $config
* @return array $temp
*/
function _initConfig($config) {
$temp = array();
$temp['sort'] = $config['sort'];
$temp['sorttype'] = isset($config['sorttype']) ? $config['sorttype'] : '';
return $temp;
}

查找一下方法修改为如下
/**
* 查找符合条件的数据
* @param array $config
* @param int $num
* @return array
*/
function _getData($config, $num,$type='broker') {
$brokerService = $this->_getBrokerService();
$AgencyService = $this->_getAgencyService();
switch ($type) {
case 'broker':
$result = $brokerService->findBrokers(array('ifactive'=>1), 1, $num, $config['sort']);
return $result[0];
case 'agency':
$result = $AgencyService->findAgencys(array('isopen'=>1), 1, $num,"vieworder");
return $result[0];
default:
return array();
}
}

添加新方法
/**
* 处理数据
* @param unknown_type $data 数据库取得的数据
* @return unknown_type $data 处理后的数据
*/
function _cookAgencyidData($data) {
if (!S::isArray($data) || empty($data['agencyid'])) return $data;
$data['url'] = 'index.php?m=house&q=agency&agencyid=' . $data['agencyid'];
$data['title'] = $data['name'];
$data['tel'] = $data['phone'] ? $data['phone'] : $data['tel'];
$data['phone'] = $data['phone'] ? $data['phone'] : $data['tel'];
$data['image'] = '/attachment/'. $data['icon'];
$_tes='';
foreach ($data as $key => $value) {
$_tes .= $key .'#'.$value.'@';
}
$data['test4'] = $_tes . 'test4';
return $data;
}

添加新方法
/**
* 载入中介公司服务类
*/
function _getAgencyService() {
return House::loadService('HouseAgencyService');
}

到此修改完成。然后到房产也修改数据来源 测试成功。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐