<?php
/**
 * 经纪人首页推荐
 * 每星期执行一次
 */
require('path.inc.php');

$query->execute("update fke_member set order_weight=0");
$query->execute("update fke_member set top_day=top_day+1 where top_day>0");
$query->execute("update fke_member set top_day=0 where top_day =5");

//计算二手房A+房源的单价比
$sql ="select * from fke_member as m  
	left join fke_broker_info as b 
	on m.id=b.id 
where m.user_type=1 and b.idcard<>'' 
	and m.sell_num+m.rent_num >=20 
	and  m.active_rate>4000";
$query->open($sql);
while ($rs = $query->next()) {
	$housesell_num = $query->getValue("select count(*) as num from fke_housesell where order_weight<>0 and broker_id = ".$rs['id']);

	$houserent_num = $query->getValue("select count(*) as num from fke_houserent where order_weight<>0 and broker_id = ".$rs['id']);
	
	$order_weight= (($housesell_num+$houserent_num)+$rs['scores']/1000)/($rs['sell_num']+$rs['rent_num']);
	$query_mysql->execute('update fke_member set order_weight='.$order_weight.' where id='.$rs['id']);
}

$query->open("select * from fke_member where top_day =0 and status = 0 and user_type=1 order by order_weight desc , sell_num desc limit 0,2");
while ($rs = $query->next()) {
	$query_mysql->execute('update fke_member set top_day=1 where id = '.$rs['id']);
}
echo "A+经纪人更新完成";

?>