<?php
/**
 * 全站数量统计
 * 时间可根据具体情况定
 * 暂定一个小时
 */

require('path.inc.php');

$houseSell= new HouseSell($query);
$housesell_num = $houseSell->getCount(0,' and (status =1 or status =2 ) ');
$query->execute("update fke_statistics set stat_value = ".$housesell_num." where stat_index ='sellNum'");

$houseRent= new HouseRent($query);
$houserent_num = $houseRent->getCount(0,' and (status =1 or status =2 ) ');
$query->execute("update fke_statistics set stat_value = ".$houserent_num." where stat_index ='rentNum'");

$borough = new Borough($query);
$borough_num = $borough->getCount(0,' and isdel = 0 ');
$query->execute("update fke_statistics set stat_value = ".$borough_num." where stat_index ='boroughNum'");

$member = new Member($query);

$broker_num = $member->getCount(' status =0 and user_type = 1 ');
$query->execute("update fke_statistics set stat_value = ".$broker_num." where stat_index ='brokerNum'");

$owner_num = $member->getCount(' status =0 and user_type = 2  ');
$query->execute("update fke_statistics set stat_value = ".$owner_num." where stat_index ='ownerNum'");


$sumPrice = $query->getValue("select sum(house_price/house_totalarea) from fke_housesell where status =1 or status =2 ");
/*
$query->open("select house_price,house_totalarea sumavg from fke_housesell where where status =1 or status =2 order by house_price/house_totalarea desc limit 0,100");
while ($rs = $query->next()) {
	$sum1 += $rs['house_price']/$rs['house_totalarea'];
}
$query->open("select house_price,house_totalarea sumavg from fke_housesell where where status =1 or status =2 order by house_price/house_totalarea asc limit 0,100");
while ($rs = $query->next()) {
	$sum2 += $rs['sumavg'];
}
$allprice = $allprice-$sum1-$sum2;
$avgPrice =$allprice/($housesell_num-200);
*/



$avgPrice = $sumPrice*10000/$housesell_num;
$query->execute("update fke_statistics set stat_value = ".$avgPrice." where stat_index ='avgprice'");

print_r("整站数据统计完成");
exit;
?>