CREATE TABLE IF NOT EXISTS `pw_house_expired` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `datatype` tinyint(1) NOT NULL DEFAULT '0',
  `expiredtype` tinyint(1) NOT NULL DEFAULT '0',
  `houseid` int(10) NOT NULL DEFAULT '0',
  `expiredtime` int(10) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `datatype` (`datatype`,`houseid`,`expiredtype`),
  KEY `expiredtime` (`expiredtime`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `pw_house_secondpost` (
  `uid` int(10) NOT NULL DEFAULT '0',
  `salenum` int(10) NOT NULL DEFAULT '0',
  `hirenum` int(10) NOT NULL DEFAULT '0',
  `todaysalenum` smallint(6) NOT NULL DEFAULT '0',
  `lastsaletime` int(10) NOT NULL DEFAULT '0',
  `todayhirenum` smallint(10) NOT NULL DEFAULT '0',
  `lasthiretime` int(10) NOT NULL DEFAULT '0',
  `ifbroker` tinyint(3) NOT NULL DEFAULT '0',
  PRIMARY KEY (`uid`),
  KEY `idx_salenum` (`salenum`),
  KEY `idx_hirenum` (`hirenum`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `pw_house_saleinfo` (
  `houseid` int(8) NOT NULL AUTO_INCREMENT,
  `areatype` tinyint(3) NOT NULL DEFAULT '0',
  `platetype` tinyint(3) NOT NULL DEFAULT '0',
  `pricetype` tinyint(3) NOT NULL DEFAULT '0',
  `acreagetype` tinyint(3) NOT NULL DEFAULT '0',
  `roomtype` tinyint(3) NOT NULL DEFAULT '0',
  `housetype` tinyint(3) NOT NULL DEFAULT '0',
  `subject` varchar(100) NOT NULL DEFAULT ' ',
  `uid` int(10) NOT NULL DEFAULT '0',
  `username` varchar(15) NOT NULL DEFAULT ' ',
  `istop` tinyint(3) NOT NULL DEFAULT '0',
  `isurgent` tinyint(3) NOT NULL DEFAULT '0',
  `isbroker` tinyint(3) NOT NULL DEFAULT '0',
  `acreage` float NOT NULL DEFAULT '0',
  `currentfloor` tinyint(3) NOT NULL DEFAULT '0',
  `totalfloor` tinyint(3) NOT NULL DEFAULT '0',
  `price` int(10) NOT NULL DEFAULT '0',
  `unitprice` int(10) NOT NULL DEFAULT '0',
  `room` smallint(6) NOT NULL DEFAULT '0',
  `righter` tinyint(3) NOT NULL DEFAULT '0',
  `village` varchar(50) NOT NULL DEFAULT ' ',
  `address` varchar(50) NOT NULL DEFAULT ' ',
  `buildtime` smallint(6) NOT NULL DEFAULT '0',
  `traffic` varchar(100) NOT NULL DEFAULT ' ',
  `fitment` tinyint(3) NOT NULL DEFAULT '0',
  `equipment` varchar(50) NOT NULL DEFAULT ' ',
  `thumb` varchar(50) NOT NULL DEFAULT ' ',
  `state` tinyint(3) NOT NULL DEFAULT '0',
  `descrip` text CHARACTER SET gbk,
  `gate` varchar(200) NOT NULL DEFAULT ' ',
  `linkman` varchar(50) NOT NULL DEFAULT ' ',
  `posttime` int(10) NOT NULL DEFAULT '0',
  `modifytime` int(10) NOT NULL DEFAULT '0',
  PRIMARY KEY (`houseid`),
  KEY `idx_modifytime` (`modifytime`),
  KEY `idx_posttime` (`posttime`),
  KEY `idx_uid` (`uid`),
  KEY `idx_status` (`state`),
  KEY `idx_price` (`price`),
  KEY `idx_unitprice` (`unitprice`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `pw_house_salemodifytime_index` (
  `houseid` int(8) NOT NULL,
  `areatype` tinyint(3) NOT NULL DEFAULT '0',
  `platetype` tinyint(3) NOT NULL DEFAULT '0',
  `pricetype` tinyint(3) NOT NULL DEFAULT '0',
  `acreagetype` tinyint(3) NOT NULL DEFAULT '0',
  `roomtype` tinyint(3) NOT NULL DEFAULT '0',
  `housetype` tinyint(3) NOT NULL DEFAULT '0',
  `modifytime` int(10) NOT NULL DEFAULT '0',
  KEY `idx_houseid` (`houseid`),
  KEY `idx_price_acreage_room_house_modifytime` (`pricetype`,`acreagetype`,`roomtype`,`housetype`,`modifytime`),
  KEY `idx_acreage_room_house_modifytime` (`acreagetype`,`roomtype`,`housetype`,`modifytime`),
  KEY `idx_room_house_modifytime` (`roomtype`,`housetype`,`modifytime`),
  KEY `idx_house_modifytime` (`housetype`,`modifytime`),
  KEY `idx_area_plate_price_acreage_room_house_modifytime` (`areatype`,`platetype`,`pricetype`,`acreagetype`,`roomtype`,`housetype`,`modifytime`),
  KEY `idx_plate_price_acreage_room_house_modifytime` (`platetype`,`pricetype`,`acreagetype`,`roomtype`,`housetype`,`modifytime`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `pw_house_saleoverdue` (
  `houseid` int(8) NOT NULL DEFAULT '0',
  `areatype` tinyint(3) NOT NULL DEFAULT '0',
  `platetype` tinyint(3) NOT NULL DEFAULT '0',
  `pricetype` tinyint(3) NOT NULL DEFAULT '0',
  `acreagetype` tinyint(3) NOT NULL DEFAULT '0',
  `roomtype` tinyint(3) NOT NULL DEFAULT '0',
  `housetype` tinyint(3) NOT NULL DEFAULT '0',
  `modifytime` int(10) NOT NULL DEFAULT '0',
  `posttime` int(10) NOT NULL DEFAULT '0',
  `price` int(10) NOT NULL DEFAULT '0',
  `unitprice` int(10) NOT NULL DEFAULT '0',
  KEY `idx_houseid` (`houseid`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `pw_house_saleposttime_index` (
  `houseid` int(8) NOT NULL,
  `areatype` tinyint(3) NOT NULL DEFAULT '0',
  `platetype` tinyint(3) NOT NULL DEFAULT '0',
  `pricetype` tinyint(3) NOT NULL DEFAULT '0',
  `acreagetype` tinyint(3) NOT NULL DEFAULT '0',
  `roomtype` tinyint(3) NOT NULL DEFAULT '0',
  `housetype` tinyint(3) NOT NULL DEFAULT '0',
  `posttime` int(10) NOT NULL DEFAULT '0',
  KEY `idx_houseid` (`houseid`),
  KEY `idx_price_acreage_room_house_posttime` (`pricetype`,`acreagetype`,`roomtype`,`housetype`,`posttime`),
  KEY `idx_acreage_room_house_posttime` (`acreagetype`,`roomtype`,`housetype`,`posttime`),
  KEY `idx_room_house_posttime` (`roomtype`,`housetype`,`posttime`),
  KEY `idx_house_posttime` (`housetype`,`posttime`),
  KEY `idx_plate_price_acreage_room_house_posttime` (`platetype`,`pricetype`,`acreagetype`,`roomtype`,`housetype`,`posttime`),
  KEY `idx_area_plate_price_acreage_room_house_posttime` (`areatype`,`platetype`,`pricetype`,`acreagetype`,`roomtype`,`housetype`,`posttime`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `pw_house_saleprice_index` (
  `houseid` int(8) NOT NULL,
  `areatype` tinyint(3) NOT NULL DEFAULT '0',
  `platetype` tinyint(3) NOT NULL DEFAULT '0',
  `pricetype` tinyint(3) NOT NULL DEFAULT '0',
  `acreagetype` tinyint(3) NOT NULL DEFAULT '0',
  `roomtype` tinyint(3) NOT NULL DEFAULT '0',
  `housetype` tinyint(3) NOT NULL DEFAULT '0',
  `price` int(10) NOT NULL DEFAULT '0',
  KEY `idx_houseid` (`houseid`),
  KEY `idx_price_acreage_room_house_price` (`pricetype`,`acreagetype`,`roomtype`,`housetype`,`price`),
  KEY `idx_acreage_room_house_price` (`acreagetype`,`roomtype`,`housetype`,`price`),
  KEY `idx_room_house_price` (`roomtype`,`housetype`,`price`),
  KEY `idx_house_price` (`housetype`,`price`),
  KEY `idx_area_plate_price_acreage_room_house_price` (`areatype`,`platetype`,`pricetype`,`acreagetype`,`roomtype`,`housetype`,`price`),
  KEY `idx_plate_price_acreage_room_house_price` (`platetype`,`pricetype`,`acreagetype`,`roomtype`,`housetype`,`price`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `pw_house_saleunitprice_index` (
  `houseid` int(8) NOT NULL,
  `areatype` tinyint(3) NOT NULL DEFAULT '0',
  `platetype` tinyint(3) NOT NULL DEFAULT '0',
  `pricetype` tinyint(3) NOT NULL DEFAULT '0',
  `acreagetype` tinyint(3) NOT NULL DEFAULT '0',
  `roomtype` tinyint(3) NOT NULL DEFAULT '0',
  `housetype` tinyint(3) NOT NULL DEFAULT '0',
  `unitprice` int(10) NOT NULL DEFAULT '0',
  KEY `idx_houseid` (`houseid`),
  KEY `idx_price_acreage_room_house_unitprice` (`pricetype`,`acreagetype`,`roomtype`,`housetype`,`unitprice`),
  KEY `idx_acreage_room_house_unitprice` (`acreagetype`,`roomtype`,`housetype`,`unitprice`),
  KEY `idx_room_house_unitprice` (`roomtype`,`housetype`,`unitprice`),
  KEY `idx_house_unitprice` (`housetype`,`unitprice`),
  KEY `idx_area_plate_price_acreage_room_house_unitprice` (`areatype`,`platetype`,`pricetype`,`acreagetype`,`roomtype`,`housetype`,`unitprice`),
  KEY `idx_plate_price_acreage_room_house_unitprice` (`platetype`,`pricetype`,`acreagetype`,`roomtype`,`housetype`,`unitprice`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `pw_house_hireinfo` (
  `houseid` int(8) NOT NULL AUTO_INCREMENT,
  `areatype` tinyint(3) NOT NULL DEFAULT '0',
  `platetype` tinyint(3) NOT NULL DEFAULT '0',
  `pricetype` tinyint(3) NOT NULL DEFAULT '0',
  `housetype` tinyint(3) NOT NULL DEFAULT '0',
  `roomtype` tinyint(3) NOT NULL DEFAULT '0',
  `hiretype` tinyint(3) NOT NULL DEFAULT '0',
  `subject` varchar(100) NOT NULL DEFAULT ' ',
  `uid` int(10) NOT NULL DEFAULT '0',
  `username` varchar(15) NOT NULL DEFAULT ' ',
  `ischarge` tinyint(3) NOT NULL DEFAULT '0',
  `istop` tinyint(3) NOT NULL DEFAULT '0',
  `isurgent` tinyint(3) NOT NULL,
  `isbroker` tinyint(3) NOT NULL DEFAULT '0',
  `acreage` float NOT NULL DEFAULT '0',
  `currentfloor` tinyint(3) NOT NULL DEFAULT '0',
  `totalfloor` tinyint(3) NOT NULL DEFAULT '0',
  `price` int(10) NOT NULL DEFAULT '0',
  `room` smallint(6) NOT NULL DEFAULT '0',
  `village` varchar(50) NOT NULL DEFAULT ' ',
  `address` varchar(50) NOT NULL DEFAULT ' ',
  `buildtime` smallint(6) NOT NULL DEFAULT '0',
  `traffic` varchar(100) NOT NULL DEFAULT ' ',
  `fitment` tinyint(3) NOT NULL DEFAULT '0',
  `equipment` varchar(20) NOT NULL DEFAULT ' ',
  `thumb` varchar(50) NOT NULL DEFAULT ' ',
  `state` tinyint(1) NOT NULL DEFAULT '0',
  `descrip` text,
  `gate` varchar(200) NOT NULL DEFAULT ' ',
  `linkman` varchar(50) NOT NULL DEFAULT ' ',
  `posttime` int(10) NOT NULL DEFAULT '0',
  `modifytime` int(10) NOT NULL DEFAULT '0',
  PRIMARY KEY (`houseid`),
  KEY `idx_modifytime` (`modifytime`),
  KEY `idx_posttime` (`posttime`),
  KEY `idx_uid` (`uid`),
  KEY `idx_state` (`state`),
  KEY `idx_price` (`price`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `pw_house_hiremodifytime_index` (
  `houseid` int(8) NOT NULL,
  `areatype` tinyint(3) NOT NULL DEFAULT '0',
  `platetype` tinyint(3) NOT NULL DEFAULT '0',
  `pricetype` tinyint(3) NOT NULL DEFAULT '0',
  `housetype` tinyint(3) NOT NULL DEFAULT '0',
  `roomtype` tinyint(3) NOT NULL DEFAULT '0',
  `hiretype` tinyint(3) NOT NULL DEFAULT '0',
  `modifytime` int(10) NOT NULL DEFAULT '0',
  KEY `idx_houseid` (`houseid`),
  KEY `idx_price_house_room_hire_modifytime` (`pricetype`,`housetype`,`roomtype`,`hiretype`,`modifytime`),
  KEY `idx_house_room_hire_modifytime` (`housetype`,`roomtype`,`hiretype`,`modifytime`),
  KEY `idx_room_hire_modifytime` (`roomtype`,`hiretype`,`modifytime`),
  KEY `idx_hire_modifytime` (`hiretype`,`modifytime`),
  KEY `idx_area_plate_price_house_room_hire_modifytime` (`areatype`,`platetype`,`pricetype`,`housetype`,`roomtype`,`hiretype`,`modifytime`),
  KEY `idx_plate_price_house_room_hire_modifytime` (`platetype`,`pricetype`,`housetype`,`roomtype`,`hiretype`,`modifytime`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `pw_house_hireoverdue` (
  `houseid` int(8) NOT NULL DEFAULT '0',
  `areatype` tinyint(3) NOT NULL DEFAULT '0',
  `platetype` tinyint(3) NOT NULL DEFAULT '0',
  `pricetype` tinyint(3) NOT NULL DEFAULT '0',
  `housetype` tinyint(3) NOT NULL DEFAULT '0',
  `roomtype` tinyint(3) NOT NULL DEFAULT '0',
  `hiretype` tinyint(3) NOT NULL DEFAULT '0',
  `posttime` int(10) NOT NULL DEFAULT '0',
  `modifytime` int(10) NOT NULL DEFAULT '0',
  `price` int(10) NOT NULL DEFAULT '0',
  KEY `idx_houseid` (`houseid`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `pw_house_hireposttime_index` (
  `houseid` int(8) NOT NULL,
  `areatype` tinyint(3) NOT NULL DEFAULT '0',
  `platetype` tinyint(3) NOT NULL DEFAULT '0',
  `pricetype` tinyint(3) NOT NULL DEFAULT '0',
  `housetype` tinyint(3) NOT NULL DEFAULT '0',
  `roomtype` tinyint(3) NOT NULL DEFAULT '0',
  `hiretype` tinyint(3) NOT NULL DEFAULT '0',
  `posttime` int(10) NOT NULL DEFAULT '0',
  KEY `idx_houseid` (`houseid`),
  KEY `idx_price_house_room_hire_posttime` (`pricetype`,`housetype`,`roomtype`,`hiretype`,`posttime`),
  KEY `idx_house_room_hire_posttime` (`housetype`,`roomtype`,`hiretype`,`posttime`),
  KEY `idx_room_hire_posttime` (`roomtype`,`hiretype`,`posttime`),
  KEY `idx_hire_posttime` (`hiretype`,`posttime`),
  KEY `idx_area_plate_price_house_room_hire_posttime` (`areatype`,`platetype`,`pricetype`,`housetype`,`roomtype`,`hiretype`,`posttime`),
  KEY `idx_plate_price_house_room_hire_posttime` (`platetype`,`pricetype`,`housetype`,`roomtype`,`hiretype`,`posttime`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `pw_house_hireprice_index` (
  `houseid` int(8) NOT NULL,
  `areatype` tinyint(3) NOT NULL DEFAULT '0',
  `platetype` tinyint(3) NOT NULL DEFAULT '0',
  `pricetype` tinyint(3) NOT NULL DEFAULT '0',
  `housetype` tinyint(3) NOT NULL DEFAULT '0',
  `roomtype` tinyint(3) NOT NULL DEFAULT '0',
  `hiretype` tinyint(3) NOT NULL DEFAULT '0',
  `price` int(10) NOT NULL DEFAULT '0',
  KEY `idx_houseid` (`houseid`),
  KEY `idx_price_house_room_hire_price` (`pricetype`,`housetype`,`roomtype`,`hiretype`,`price`),
  KEY `idx_house_room_hire_price` (`housetype`,`roomtype`,`hiretype`,`price`),
  KEY `idx_room_hire_price` (`roomtype`,`hiretype`,`price`),
  KEY `idx_hire_price` (`hiretype`,`price`),
  KEY `idx_area_plate_price_house_room_hire_price` (`areatype`,`platetype`,`pricetype`,`housetype`,`roomtype`,`hiretype`,`price`),
  KEY `idx_plate_price_house_room_hire_price` (`platetype`,`pricetype`,`housetype`,`roomtype`,`hiretype`,`price`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `pw_house_personal` (
  `houseid` int(10) NOT NULL DEFAULT '0',
  `datatype` tinyint(1) NOT NULL DEFAULT '0',
  `linkman` varchar(50) NOT NULL DEFAULT ' ',
  `phone` varchar(15) NOT NULL DEFAULT ' ',
  `tel` varchar(15) NOT NULL DEFAULT ' ',
  `email` varchar(50) NOT NULL DEFAULT ' ',
  KEY `idx_houseid` (`houseid`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `pw_house_secondimage` (
  `imageid` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `type` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `houseid` int(10) unsigned NOT NULL DEFAULT '0',
  `size` int(10) unsigned NOT NULL DEFAULT '0',
  `path` varchar(100) NOT NULL DEFAULT '',
  `uploadtime` int(10) NOT NULL DEFAULT '0',
  `descrip` varchar(255) NOT NULL DEFAULT '',
  `creator` varchar(20) NOT NULL DEFAULT '',
  `name` varchar(30) NOT NULL DEFAULT '',
  PRIMARY KEY (`imageid`),
  KEY `idx_type` (`type`,`houseid`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `pw_house_report` (
  `reportid` mediumint(8) NOT NULL AUTO_INCREMENT,
  `uid` int(10) NOT NULL DEFAULT '0',
  `username` varchar(15) NOT NULL DEFAULT '',
  `reason` text NOT NULL,
  `handle` tinyint(3) NOT NULL DEFAULT '0',
  `type` tinyint(3) NOT NULL DEFAULT '0',
  `id` int(10) NOT NULL DEFAULT '0',
  `time` int(10) NOT NULL DEFAULT '0',
  PRIMARY KEY (`reportid`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `pw_house_brokergroup` (
  `groupid` tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(30) NOT NULL DEFAULT '',
  `usernum` smallint(6) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`groupid`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `pw_house_brokerright` (
  `groupid` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `rightkey` varchar(30) NOT NULL,
  `rightvalue` varchar(30) NOT NULL,
  UNIQUE KEY `groupid` (`groupid`,`rightkey`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `pw_house_broker` (
  `uid` int(10) NOT NULL DEFAULT '0',
  `username` varchar(15) NOT NULL DEFAULT '',
  `groupid` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `realname` varchar(30) NOT NULL DEFAULT '',
  `ifactive` tinyint(3) NOT NULL DEFAULT '1',
  `area` int(10) NOT NULL DEFAULT '0',
  `plate` text NOT NULL,
  `company` varchar(30) NOT NULL DEFAULT '',
  `address` varchar(150) NOT NULL DEFAULT '',
  `email` varchar(50) NOT NULL DEFAULT '',
  `tel` varchar(15) NOT NULL DEFAULT '',
  `phone` varchar(15) NOT NULL DEFAULT '',
  `verify` int(10) unsigned NOT NULL DEFAULT '0',
  `idcard` char(18) NOT NULL DEFAULT '',
  `idcardpic` varchar(100) NOT NULL DEFAULT '',
  `alipay` varchar(50) NOT NULL DEFAULT '',
  `otherinfo` varchar(255) NOT NULL DEFAULT '',
  `remark` varchar(255) NOT NULL DEFAULT '',
  `createtime` int(10) unsigned NOT NULL DEFAULT '0',
  `announce` text,
  `business` char(4) DEFAULT '',
  KEY `idx_uid` (`uid`),
  KEY `idx_createtime` (`createtime`),
  KEY `idx_groupid` (`groupid`),
  KEY `idx_username` (`username`),
  KEY `idx_realname` (`realname`)
) ENGINE=MyISAM;

CREATE TABLE `pw_house_area` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `code` varchar(8) NOT NULL,
  `name` varchar(60) NOT NULL,
  `ifopen` tinyint(1) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `code` (`code`)
) ENGINE=MyISAM;

CREATE TABLE `pw_house_developer` (
  `id` mediumint(8) NOT NULL AUTO_INCREMENT,
  `name` varchar(80) NOT NULL,
  `level` varchar(120) NOT NULL,
  `address` varchar(120) NOT NULL,
  `zipcode` varchar(6) NOT NULL,
  `email` varchar(60) NOT NULL,
  `url` varchar(120) NOT NULL,
  `principal` varchar(20) NOT NULL,
  `linkman` varchar(20) NOT NULL,
  `tel` varchar(30) NOT NULL,
  `fax` varchar(30) NOT NULL,
  `introduction` text NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM;

CREATE TABLE `pw_house_evaluations` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `uid` mediumint(8) unsigned NOT NULL,
  `username` varchar(50) NOT NULL DEFAULT '',
  `hid` mediumint(8) unsigned NOT NULL,
  `hname` varchar(50) NOT NULL,
  `ctime` int(10) unsigned NOT NULL,
  `ctype` enum('evaluation','score') NOT NULL DEFAULT 'evaluation',
  `content` text NOT NULL,
  `total` text NOT NULL,
  `ifcheck` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0:没有通过审核 1:通过审核',
  PRIMARY KEY (`id`),
  KEY `hid` (`hid`),
  KEY `uid` (`uid`),
  KEY `hname` (`hname`)
) ENGINE=MyISAM;

CREATE TABLE `pw_house_feed` (
  `id` mediumint(8) NOT NULL AUTO_INCREMENT,
  `hid` mediumint(8) NOT NULL,
  `postdate` int(10) unsigned NOT NULL,
  `descrip` text NOT NULL,
  `adddate` int(10) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `hid` (`hid`)
) ENGINE=MyISAM;

CREATE TABLE `pw_house_fields` (
  `id` smallint(6) unsigned NOT NULL AUTO_INCREMENT,
  `type` varchar(20) NOT NULL,
  `fieldvalue` varchar(80) NOT NULL,
  `vieworder` smallint(6) NOT NULL,
  `ifopen` tinyint(1) NOT NULL,
  PRIMARY KEY (`type`,`id`)
) ENGINE=MyISAM;

CREATE TABLE `pw_house_groupbuy` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `uid` mediumint(8) unsigned NOT NULL DEFAULT '0' COMMENT '未注册 游客',
  `author` varchar(40) NOT NULL DEFAULT '游客' COMMENT '论坛用户名',
  `hid` mediumint(8) unsigned NOT NULL,
  `hname` varchar(40) NOT NULL DEFAULT '',
  `username` varchar(40) NOT NULL DEFAULT '' COMMENT '真实姓名',
  `gender` tinyint(2) NOT NULL DEFAULT '0' COMMENT '0男性 1女性',
  `phone` varchar(20) NOT NULL DEFAULT '',
  `mobel` varchar(20) NOT NULL DEFAULT '',
  `qq` varchar(30) NOT NULL DEFAULT '',
  `msn` varchar(60) NOT NULL DEFAULT '',
  `email` varchar(60) NOT NULL DEFAULT '',
  `budget` smallint(6) unsigned NOT NULL DEFAULT '0',
  `area` smallint(6) unsigned NOT NULL DEFAULT '0',
  `ctime` int(10) unsigned NOT NULL,
  `remark` text NOT NULL,
  PRIMARY KEY (`id`),
  KEY `hname` (`hname`),
  KEY `budget` (`budget`),
  KEY `area` (`area`),
  KEY `ctime` (`ctime`)
) ENGINE=MyISAM;

CREATE TABLE `pw_house_image` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `typeid` smallint(6) unsigned NOT NULL,
  `hid` int(10) unsigned NOT NULL,
  `size` int(10) unsigned NOT NULL,
  `path` varchar(80) NOT NULL,
  `uploadtime` int(10) NOT NULL,
  `descrip` varchar(255) NOT NULL,
  `creator` varchar(20) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `typeid` (`typeid`),
  KEY `hid` (`hid`,`typeid`)
) ENGINE=MyISAM;

CREATE TABLE `pw_house_imagedata` (
  `imageid` int(10) unsigned NOT NULL,
  `hits` int(10) NOT NULL,
  PRIMARY KEY (`imageid`)
) ENGINE=MyISAM;

CREATE TABLE `pw_house_imagetype` (
  `id` smallint(6) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(25) NOT NULL,
  `sub` smallint(6) unsigned NOT NULL DEFAULT '0',
  `position` smallint(6) unsigned NOT NULL DEFAULT '0',
  `ifuse` tinyint(1) unsigned NOT NULL DEFAULT '1',
  `ifsystem` tinyint(1) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `name` (`name`)
) ENGINE=MyISAM;

CREATE TABLE `pw_house_info` (
  `hid` mediumint(8) NOT NULL AUTO_INCREMENT,
  `name` varchar(40) NOT NULL,
  `ifopen` tinyint(1) unsigned NOT NULL,
  `recommend` tinyint(1) unsigned NOT NULL,
  `logo` varchar(80) NOT NULL,
  `banner` varchar(80) NOT NULL,
  `property` int(10) unsigned NOT NULL,
  `buildtype` int(10) unsigned NOT NULL,
  `area` mediumint(8) unsigned NOT NULL,
  `plate` mediumint(8) unsigned NOT NULL,
  `housetype` mediumint(8) unsigned NOT NULL,
  `address` varchar(120) NOT NULL,
  `saletele` varchar(30) NOT NULL,
  `saleaddress` varchar(120) NOT NULL,
  `developer` mediumint(8) unsigned NOT NULL,
  `aveprice` mediumint(8) unsigned NOT NULL,
  `status` mediumint(8) unsigned NOT NULL,
  `sellinglicense` varchar(120) NOT NULL,
  `paystatus` tinyint(10) unsigned NOT NULL,
  `opendate` int(10) NOT NULL,
  `deliverdate` int(10) NOT NULL,
  `buildingarea` mediumint(8) unsigned NOT NULL,
  `floorspace` mediumint(8) unsigned NOT NULL,
  `plotratio` decimal(5,2) NOT NULL,
  `greenratio` decimal(5,2) NOT NULL,
  `carport` smallint(6) unsigned NOT NULL,
  `carportfee` decimal(8,2) unsigned NOT NULL,
  `cleaningfee` decimal(8,2) NOT NULL,
  `adddate` int(10) NOT NULL,
  `postnum` int(10) unsigned NOT NULL,
  `groupbuynum` int(10) unsigned NOT NULL,
  `collectnum` int(10) unsigned NOT NULL,
  `hits` int(10) unsigned NOT NULL,
  `score` smallint(6) unsigned NOT NULL,
  `cyid` mediumint(8) unsigned NOT NULL,
  `tags` varchar(255) NOT NULL,
  PRIMARY KEY (`hid`),
  KEY `area` (`area`),
  KEY `aveprice` (`aveprice`)
) ENGINE=MyISAM;

CREATE TABLE `pw_house_infoextra` (
  `hid` mediumint(8) unsigned NOT NULL,
  `traffic` varchar(255) NOT NULL,
  `propertycompany` varchar(80) NOT NULL,
  `peripheral` text NOT NULL,
  `introduction` text NOT NULL,
  `nav` text NOT NULL,
  `seotitle` varchar(80) NOT NULL,
  `seokeywords` varchar(250) NOT NULL,
  `seodescription` text NOT NULL,
  PRIMARY KEY (`hid`)
) ENGINE=MyISAM;

CREATE TABLE `pw_house_map` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `hid` mediumint(8) unsigned NOT NULL,
  `x` varchar(20) DEFAULT '0',
  `y` varchar(20) DEFAULT '0',
  `zoom` smallint(2) NOT NULL COMMENT ' 3 - 17',
  `laber` text,
  PRIMARY KEY (`id`),
  UNIQUE KEY `hid` (`hid`),
  KEY `x` (`hid`,`x`,`y`)
) ENGINE=MyISAM;

CREATE TABLE `pw_house_pagecache` (
  `sign` char(32) NOT NULL,
  `type` varchar(30) NOT NULL,
  `data` text NOT NULL,
  `cachetime` int(10) unsigned NOT NULL,
  PRIMARY KEY (`sign`),
  KEY `type` (`type`)
) ENGINE=MyISAM;

CREATE TABLE `pw_house_pricedetail` (
  `id` smallint(8) unsigned NOT NULL AUTO_INCREMENT,
  `hid` smallint(8) unsigned NOT NULL,
  `title` varchar(30) NOT NULL DEFAULT '',
  `propertyid` smallint(6) unsigned NOT NULL,
  `buildtypeid` smallint(6) unsigned NOT NULL,
  `paystatusid` smallint(6) unsigned NOT NULL,
  `currentprice` varchar(10) NOT NULL,
  `opentime` int(11) unsigned NOT NULL,
  `paytime` int(11) unsigned NOT NULL,
  `hnum` smallint(6) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `hid` (`hid`)
) ENGINE=MyISAM;

CREATE TABLE `pw_house_pushdata` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `hid` mediumint(8) unsigned NOT NULL,
  `model` varchar(30) NOT NULL,
  `title` varchar(255) NOT NULL,
  `titlecss` varchar(255) NOT NULL,
  `url` varchar(100) NOT NULL,
  `image` varchar(100) NOT NULL,
  `data` text NOT NULL,
  `offset` smallint(6) NOT NULL,
  `author` varchar(20) NOT NULL,
  `pushtime` int(10) NOT NULL,
  `iffailure` tinyint(1) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `hid` (`hid`,`model`),
  KEY `iffailure` (`iffailure`),
  KEY `iffailure_2` (`iffailure`)
) ENGINE=MyISAM;

CREATE TABLE `pw_house_recommend` (
  `hid` mediumint(8) unsigned NOT NULL,
  `timestamp` int(10) unsigned NOT NULL,
  PRIMARY KEY (`hid`)
) ENGINE=MyISAM;


CREATE TABLE `pw_house_userscore` (
  `hid` mediumint(8) unsigned NOT NULL,
  `uid` mediumint(8) unsigned NOT NULL,
  `stime` int(10) unsigned NOT NULL,
  `content` text NOT NULL,
  PRIMARY KEY (`hid`,`uid`)
) ENGINE=MyISAM;

CREATE TABLE `pw_house_video` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `hid` mediumint(8) unsigned NOT NULL,
  `address` text NOT NULL,
  `image` varchar(255) NOT NULL,
  `uploadtime` int(10) NOT NULL,
  `descrip` varchar(255) NOT NULL,
  `ifembed` tinyint(1) NOT NULL,
  `creator` varchar(25) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `hid` (`hid`)
) ENGINE=MyISAM;

CREATE TABLE `pw_house_vrange` (
  `id` smallint(6) NOT NULL AUTO_INCREMENT,
  `type` varchar(20) NOT NULL,
  `fieldvalue` varchar(80) NOT NULL,
  `vstart` mediumint(8) NOT NULL,
  `vend` mediumint(8) NOT NULL,
  `vieworder` smallint(6) NOT NULL,
  `ifopen` tinyint(1) NOT NULL,
  PRIMARY KEY (`type`,`id`)
) ENGINE=MyISAM;

INSERT INTO `pw_house_imagetype` (`id`, `name`, `sub`, `position`, `ifuse`, `ifsystem`) VALUES
(1, '户型图', 0, 0, 1, 1),
(2, '样板间', 0, 0, 1, 1),
(3, '实景图', 0, 0, 1, 1),
(4, '规划图', 0, 0, 1, 1),
(5, '一室', 1, 1, 1, 0),
(6, '二室', 1, 2, 1, 0),
(7, '三室', 1, 3, 1, 0),
(8, '四室', 1, 4, 1, 0),
(9, '复式', 1, 5, 1, 0),
(10, '沙盘图', 0, 1, 1, 0);

REPLACE `pw_house_fields` (`id`, `type`, `fieldvalue`, `vieworder`, `ifopen`) VALUES
(1, 'property', '别墅', 6, 1),
(2, 'property', '普通住宅', 1, 1),
(3, 'property', '公寓', 2, 1),
(4, 'property', '花园式洋房', 3, 1),
(5, 'property', '酒店式公寓', 4, 1),
(6, 'property', '商住两用', 5, 1),
(7, 'property', '写字楼', 7, 1),
(8, 'property', '商铺', 8, 1),
(1, 'buildtype', '低层', 1, 1),
(2, 'buildtype', '多层', 2, 1),
(3, 'buildtype', '小高层', 3, 1),
(4, 'buildtype', '高层', 4, 1),
(5, 'buildtype', '超高层', 5, 1),
(1, 'paystatus', '简装修', 0, 1),
(2, 'paystatus', '毛坯', 4, 1),
(3, 'paystatus', '精装修', 1, 1),
(1, 'housetype', '学区房', 0, 1),
(2, 'housetype', '地铁房', 2, 1),
(3, 'housetype', '江景房', 3, 1),
(4, 'housetype', '景区房', 4, 1),
(5, 'housetype', '新婚房', 5, 1),
(6, 'housetype', '养老房', 6, 1),
(1, 'propertyright', '经济适用房', 4, 1),
(2, 'propertyright', '商品房', 2, 1),
(3, 'propertyright', '使用权', 3, 1),
(4, 'propertyright', '个人产权', 1, 1),
(5, 'propertyright', '公司产权', 5, 1),
(1, 'amenities', '水', 1, 1),
(2, 'amenities', '电', 2, 1),
(3, 'amenities', '煤气/天然气', 3, 1),
(4, 'amenities', '暖气', 4, 1),
(5, 'amenities', '有线电视', 5, 1),
(6, 'amenities', '宽带', 6, 1),
(7, 'amenities', '家具', 7, 1),
(8, 'amenities', '车位/车库', 8, 1),
(9, 'amenities', '电梯', 9, 1),
(1, 'score', '交通', 1, 1),
(2, 'score', '环境', 2, 1),
(3, 'score', '规划', 3, 1),
(4, 'score', '配套', 4, 1),
(5, 'score', '开发商', 5, 1);

REPLACE `pw_house_vrange` (`id`, `type`, `fieldvalue`, `vstart`, `vend`, `vieworder`, `ifopen`) VALUES
(1, 'aveprice', '3000以下', 0, 3000, 0, 1),
(2, 'aveprice', '3000-5000', 3000, 5000, 1, 1),
(3, 'aveprice', '5000-7000', 5000, 7000, 2, 1),
(4, 'aveprice', '7000-10000', 7000, 10000, 3, 1),
(5, 'aveprice', '10000-13000', 10000, 13000, 4, 1),
(6, 'aveprice', '13000-16000', 13000, 16000, 5, 1),
(7, 'aveprice', '16000-20000', 16000, 20000, 6, 1),
(8, 'aveprice', '20000-25000', 20000, 25000, 7, 1),
(9, 'aveprice', '25000以上', 25000, 0, 8, 1),
(1, 'budget', '30万以下', 0, 300000, 0, 1),
(2, 'budget', '30万-40万', 300000, 400000, 1, 1),
(3, 'budget', '40万-50万', 400000, 500000, 2, 1),
(4, 'budget', '50万-60万', 500000, 600000, 3, 1),
(5, 'budget', '60万-80万', 600000, 800000, 4, 1),
(6, 'budget', '80万以上', 800000, 0, 5, 1),
(1, 'acreage', '50平米以下', 0, 50, 0, 1),
(2, 'acreage', '50-70平米', 50, 70, 1, 1),
(3, 'acreage', '70-100平米', 70, 100, 2, 1),
(4, 'acreage', '100-150平米', 100, 150, 3, 1),
(5, 'acreage', '150-200平米', 150, 200, 4, 1),
(6, 'acreage', '200平米以上', 200, 0, 5, 1),
(1, 'rentprice', '500元以下', 0, 500, 0, 1),
(2, 'rentprice', '500-1000元', 500, 1000, 1, 1),
(3, 'rentprice', '1000-1500元', 1000, 1500, 2, 1),
(4, 'rentprice', '1500-2000元', 1500, 2000, 3, 1),
(5, 'rentprice', '2000元以上', 2000, 0, 4, 1),
(1, 'sellprice', '50万以内', 0, 50, 0, 1),
(2, 'sellprice', '50-100万', 50, 100, 1, 1),
(3, 'sellprice', '100万以上', 100, 0, 2, 1);

DELETE FROM `pw_nav` WHERE `type` = 'house_navinfo';
INSERT INTO `pw_nav` (`nkey`, `type`, `title`, `style`, `link`, `alt`, `pos`, `target`, `view`, `upid`, `isshow`) VALUES
('', 'house_navinfo', '楼盘大全', '|||', 'mode.php?m=house&q=list', '', '-1', 0, 2, 0, 1),
('', 'house_navinfo', '地图找房', '|||', 'mode.php?m=house&q=housemap&hid=20&step=searchinfo', '', '-1', 0, 3, 0, 1),
('', 'house_navinfo', '楼盘资讯', '|||', '#', '', '-1', 1, 0, 0, 1),
('', 'house_navinfo', '住宅', '|||', 'mode.php?m=house&q=list&property=2', '', '-1', 0, 0, 0, 1),
('', 'house_navinfo', '别墅', '|||', 'mode.php?m=house&q=list&property=1', '', '-1', 0, 0, 0, 1),
('', 'house_navinfo', '写字楼', '|||', 'mode.php?m=house&q=list&property=7', '', '-1', 0, 0, 1, 1),
('', 'house_navinfo', '商铺', '|||', 'mode.php?m=house&q=list&property=8', '', '-1', 0, 0, 0, 1),
('', 'house_navinfo', '业主小区', '|||', '', '', '-1', 1, 0, 0, 1);

ALTER TABLE  `pw_house_info` ADD  `isdimopendate` TINYINT( 3 ) NOT NULL DEFAULT  '0' AFTER  `deliverdate` ;
ALTER TABLE  `pw_house_info` ADD  `isdimdeliverdate` TINYINT( 3 ) NOT NULL DEFAULT  '0' AFTER  `isdimopendate` ;
ALTER TABLE `pw_house_fields` ADD `parent` SMALLINT NOT NULL DEFAULT '0';
REPLACE INTO `pw_house_brokergroup` (`groupid`, `name`, `usernum`) VALUES
(1, '普通经纪人', 0),
(2, 'VIP经纪人', 0);

REPLACE INTO `pw_house_brokerright` (`groupid`, `rightkey`, `rightvalue`) VALUES
(1, 'ifsale', '1'),
(1, 'salenum', '10'),
(1, 'ifhire', '1'),
(1, 'hirenum', '50'),
(2, 'ifsale', '1'),
(2, 'salenum', '10'),
(2, 'ifhire', '1'),
(2, 'hirenum', '50');

DELETE FROM pw_advert WHERE `type` =0 AND ckey like'%House%';
INSERT INTO `pw_advert` (`type`, `uid`, `ckey`, `stime`, `etime`, `ifshow`, `orderby`, `descrip`, `config`) VALUES
(0, 0, 'Mode.House.Index.Center4', 0, 0, 1, 0, '新房首页中间广告位4', 'a:1:{s:7:\"display\";s:3:\"all\";}'),
(0, 0, 'Mode.House.Index.Center3', 0, 0, 1, 0, '新房首页中间广告位3', 'a:1:{s:7:\"display\";s:3:\"all\";}'),
(0, 0, 'Mode.House.Index.Center2', 0, 0, 1, 0, '新房首页中间广告位2', 'a:1:{s:7:\"display\";s:3:\"all\";}'),
(0, 0, 'Mode.House.Index.Center1', 0, 0, 1, 0, '新房首页中间广告位1', 'a:1:{s:7:\"display\";s:3:\"all\";}'),
(0, 0, 'Mode.House.Index.Right4', 0, 0, 1, 0, '新房首页侧边4', 'a:1:{s:7:\"display\";s:3:\"all\";}'),
(0, 0, 'Mode.House.Index.Right3', 0, 0, 1, 0, '新房首页侧边3', 'a:1:{s:7:\"display\";s:3:\"all\";}'),
(0, 0, 'Mode.House.Index.Right2', 0, 0, 1, 0, '新房首页侧边2', 'a:1:{s:7:\"display\";s:3:\"all\";}'),
(0, 0, 'Mode.House.Index.Right1', 0, 0, 1, 0, '新房首页侧边1', 'a:1:{s:7:\"display\";s:3:\"all\";}'),
(0, 0, 'Mode.House.Info.Footer', 0, 0, 1, 0, '新房展示页底部横幅', 'a:1:{s:7:\"display\";s:4:\"rand\";}'),
(0, 0, 'Mode.House.Info.Center', 0, 0, 1, 0, '新房展示页中间横幅', 'a:1:{s:7:\"display\";s:4:\"rand\";}'),
(0, 0, 'Mode.House.List.Rigtht', 0, 0, 1, 0, '新房列表页侧边', 'a:1:{s:7:\"display\";s:4:\"rand\";}'),
(0, 0, 'Mode.House.Index.Header', 0, 0, 1, 0, '新房首页头部横幅', 'a:1:{s:7:\"display\";s:3:\"all\";}'),
(0, 0, 'Mode.House.Index.Right', 0, 0, 1, 0, '新房首页侧边', 'a:1:{s:7:\"display\";s:3:\"all\";}'),
(0, 0, 'Mode.House.Index.Center', 0, 0, 1, 0, '新房首页中间广告位', 'a:1:{s:7:\"display\";s:4:\"rand\";}'),
(0, 0, 'Mode.House.Index.Footer', 0, 0, 1, 0, '新房首页底部横幅', 'a:1:{s:7:\"display\";s:3:\"all\";}'),
(0, 0, 'Mode.House.List.Footer', 0, 0, 1, 0, '新房列表页底部横幅', 'a:1:{s:7:\"display\";s:4:\"rand\";}'),
(0, 0, 'Mode.House.Info.Right', 0, 0, 1, 0, '新房展示页侧边', 'a:1:{s:7:\"display\";s:4:\"rand\";}'),
(0, 0, 'Mode.House.Info.Header', 0, 0, 1, 0, '新房展示页头部横幅', 'a:1:{s:7:\"display\";s:4:\"rand\";}'),
(0, 0, 'Mode.House.List.Header', 0, 0, 1, 0, '新房列表页头部横幅', 'a:1:{s:7:\"display\";s:4:\"rand\";}'),
('0','0','Mode.House.Sale.Footer','0','0','1','0','二手房列表页底部横幅','a:1:{s:7:\"display\";s:4:\"rand\";}'),
('0','0','Mode.House.Sale.Left','0','0','1','0','二手房列表页右侧栏广告位','a:1:{s:7:\"display\";s:4:\"rand\";}'),
('0','0','Mode.House.Hire.Footer','0','0','1','0','出租房列表页底部横幅','a:1:{s:7:\"display\";s:4:\"rand\";}'),
('0','0','Mode.House.Hire.Left','0','0','1','0','出租房列表页右侧栏广告位','a:1:{s:7:\"display\";s:4:\"rand\";}'),
('0','0','Mode.House.Second.Center','0','0','1','0','二手房首页中间广告位','a:1:{s:7:\"display\";s:4:\"rand\";}'),
('0','0','Mode.House.Second.Left','0','0','1','0','二手房首页右侧栏广告位','a:1:{s:7:\"display\";s:4:\"rand\";}');

ALTER TABLE `pw_house_hireinfo` CHANGE `price` `price` DECIMAL( 10, 2 ) NOT NULL DEFAULT '0';
ALTER TABLE `pw_house_saleinfo` CHANGE `price` `price` DECIMAL( 10, 2 ) NOT NULL DEFAULT '0';
ALTER TABLE `pw_house_saleoverdue` CHANGE `price` `price` DECIMAL( 10, 2 ) NOT NULL DEFAULT '0';

ALTER TABLE pw_house_area ADD COLUMN `ord`  smallint(6) NOT NULL DEFAULT 0;

ALTER TABLE pw_house_saleinfo ADD COLUMN `remark` VARCHAR(255) NOT NULL DEFAULT '';

ALTER TABLE pw_house_hireinfo ADD COLUMN `remark` VARCHAR(255) NOT NULL DEFAULT '';
ALTER TABLE `pw_house_broker` add `agencyid` INT( 10 ) NOT NULL DEFAULT '0';
DROP TABLE IF EXISTS `pw_house_agency`;
CREATE TABLE `pw_house_agency` (
  `agencyid` int(10) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL DEFAULT '',
  `address` varchar(255) NOT NULL DEFAULT '',
  `icon` varchar(255) NOT NULL DEFAULT '',
  `bgimg` varchar(255) NOT NULL DEFAULT '',
  `mainbusiness` tinyint(3) NOT NULL DEFAULT '0',
  `adminname` varchar(30) NOT NULL DEFAULT '',
  `isopen` tinyint(3) NOT NULL DEFAULT '0',
  `vieworder` tinyint(3) NOT NULL DEFAULT '0',
  KEY `idx_agencyid` (`agencyid`)
) ENGINE=MyISAM;

ALTER TABLE `pw_house_broker` add `ifcompany` tinyint( 3 ) NOT NULL DEFAULT '0';
ALTER TABLE `pw_house_broker` add index `idx_agencyid_ifactive_ifcompany` (`agencyid`, `ifactive`, `ifcompany`);