Commit fe2b4bfd authored by fangliyan's avatar fangliyan

Merge branch 'refs/heads/subscribe2.0' into release

parents 3acc249e 7f6b51fe
This source diff could not be displayed because it is too large. You can view the blob instead.
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class User_Fang extends MY_Controller
{
/**
* Survey
* @author Candison <www.kandisheng.com>
*/
private $surveyConfig = array(
'nj' => array(
'surveyInfotype' => array(1,'1'),
'surveyDistrict' => array('雨花台区'),
),
'wh' => array(
'surveyInfotype' => array(1,2,3,4,5,6,'1','2','3','4','5','6'),
'surveyDistrict' => array('镜湖区', '鸠江区', '弋江区', '三山区'),
),
);
/**
* 开通支付的城市
* @var array
*/
private $openPayCitys = array(
'nj','wh'
);
/**
* 支付中台活动id
* @var array
*/
private $openPayCitysActId = array(
'nj' => 57,//89,
'wh' => 82,
);
private $surveyStatus = array(
0 => '实勘未知状态',
1 => '实勘审核中',
2 => '实勘不通过',
3 => '实勘已预约',
4 => '实勘处理中',
5 => '实勘已上传',
6 => '实勘已取消'
);
private $address = array(
'nj' => '南京市建邺区云龙山路99号江苏省建大厦B幢6楼信息中心;(地铁10号线中胜站下2A出口,向东300米)',
'wh' => '芜湖市镜湖区绿地新都会C座7层 365淘房二手房运营部',
);
function __construct()
{
parent::__construct();
$this->load->model("user_model");
$this->load->model("broker_model");
$this->load->model("pic_model");
$this->load->model("block_model");
$this->load->model("ask_model");
$this->load->model("house_model");
$this->load->model("house_statistic_model");
// 租房9折优惠券 20200507添加
$this->load->model('rent_coupon_model');
$this->load->library("user_class");
$this->load->library("apply_class");
$this->user_id = checklogin();
if( $this->user_id <= 0 )
{
jumpto( USER_CENTER.'login');
exit();
}
//关注各项数量
$this->num_1 = $this->user_model->getusercollect($this->user_id,1);
$this->num_2 = $this->user_model->getusercollect($this->user_id,2);
$this->num_3 = $this->user_model->getusercollect($this->user_id,3);
$this->num_4 = $this->user_model->getusercollect($this->user_id,4);
$this->num_5 = $this->user_model->getusercollect($this->user_id,5);
$this->num_7 = $this->user_model->getusercollect($this->user_id,7);
$this->num_8 = $this->user_model->getusercollect($this->user_id,8);
$this->num_9 = $this->user_model->getusercollect($this->user_id,9);
}
private function getAD($id=0, $width=0, $height=0)
{
/*
$databaseHost = '172.17.1.5';
$databasePort = '3306';
$databaseName = 'njhouse';
$databaseAccount = 'root';
$databasePassword = 'idontcare';
$databaseCharset = 'gbk';
// Connect
$mysql = mysql_connect(sprintf('%s:%s', $databaseHost, $databasePort), $databaseAccount, $databasePassword);
if($mysql === false){
return $defaultString;
}
// Query
$sql = sprintf('select id,filetype,width,height,href,src from news_ad where id="%s" limit 1', $id);
$result = mysql_db_query($databaseName, $sql, $mysql);
if($result === false){
return $defaultString;
}
$data = mysql_fetch_row($result);
if($data === false){
return $defaultString;
}
*/
// Config
$defaultString = '';
$adInterfaceBaseURL = 'http://adadmin.house365.com/api/ad/sort_ads.php';
// Get Data
$adInterfaceURL = sprintf('%s?city=%s&id=%s', $adInterfaceBaseURL, GB_CITY, $id);
$result = curl_get_contents($adInterfaceURL);
if(empty($result)){
return $defaultString;
}
$data = unserialize($result);
if(!isset($data[0])){
return $defaultString;
}
$data = $data[0];
// HTML
if(intval($width) == 0 && intval($height) == 0){
$width = $data['width'];
$height = $data['height'];
}
if($data['filetype'] == 'i'){
if(empty($data['href'])){
return sprintf('<img target="_blank" src="%s" width="%s" height="%s" border="0">', $data['src'], $width, $height);
}
return sprintf('<a target="_blank" href="%s"><img target="_blank" src="%s" width="%s" height="%s" border="0"></a>', $data['link'], $data['src'], $width, $height);
}
if($data['filetype'] == 'f'){
return sprintf('<embed src="%s" quality="high" width="%s" height="%s" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent">', $data['src'], $width, $height);
}
return $defaultString;
}
/**
* 用户中心首页
* @author cxf
*/
public function index()
{
global $house;
header("Location:http://newrent.house365.com/user-center/index");
die;
$data['conf_where'] = 'index';
$data['title'] = '会员中心';
$data['priceunit'] = $house['priceunit'];
$data['sell_num'] = $this->house_model->gethousenumbyuid($this->user_id,'sell',1);
$data['rent_num'] = $this->house_model->gethousenumbyuid($this->user_id,'rent',1);
$data['want_num'] = $this->user_model->get_rent_wantnum_by_uid($this->user_id,1);
$data['buy_num'] = $this->user_model->get_buynum_by_uid($this->user_id,1);
$data['user_detail'] = $this->user_model->get_userdetail($this->user_id,array('email','telno','auth_type','bank_type'));
$data = array_merge($data,$this->realNameData());
//获取最新2条房源
$newhouse = $this->user_model->newhouse( $this->user_id , 2 );
$data['newhouse'] = $newhouse;
$count_newhouse =count($newhouse);
$active_num =0;
$active_sell_num =0;
for($i=0;$i<$count_newhouse;$i++)
{
if($newhouse[$i]['esta']==1)
{
if($newhouse[$i]['tbl']=='sell')
{
$active_sell_num++;
}
$active_num++;
}
}
$sell_collect_house = $this->user_model->getcollect(3,$this->user_id,0,8); //网友关注的二手房房源
$rent_collect_house = $this->user_model->getcollect(4,$this->user_id,0,8); //网友关注的租房房源
$sell_collect_block = $this->user_model->getcollect(2,$this->user_id,0,8); //网友关注的小区
$data['sell_collect_house'] = $sell_collect_house;
$data['rent_collect_house'] = $rent_collect_house;
$data['sell_collect_block'] = $sell_collect_block;
//获取你可能感兴趣的二手房
$data['likesell'] = $this->user_model->getlikehousebyrule($active_num,$active_sell_num,$newhouse,$sell_collect_house,$sell_collect_block,$this->user_id,'sell',$active_sell_num,4);
//获取你可能感兴趣的租房
$data['likerent'] = $this->user_model->getlikehousebyrule($active_num,$active_sell_num,$newhouse,$rent_collect_house,$sell_collect_block,$this->user_id,'rent',$active_sell_num,4);
//获取你可能感兴趣的小区
$data['likeblock'] = $this->user_model->getlikehousebyrule($active_num,$active_sell_num,$newhouse,$sell_collect_house,$sell_collect_block,$this->user_id,'block',4);
//中奖通知 5.25-8.31
$data['is_win'] = $this->_get_is_win();
//BI统计 ----- start----->
$data['isa_website'] = '2,19,46';
$data['isa_city'] = GB_CITY;
$data['isa_addones'] = '';
$data['isa_url'] = 'isa.house365.com/js/analyze.js?v=2.1';
$this->load->model('package_model');
$data['limitNumGtZero'] = $this->package_model->getLimitNumGtZero();
//BI统计 ----- ent----->
/**
* Survey
* @author Candison <www.kandisheng.com>
*/
if (is_array($data['newhouse'])) {
if(GB_CITY=='nj'){
$this->load->model('survey_model');
$modelSurvey = new Survey_model();
}elseif(GB_CITY == 'wh'){
$this->load->model('vr_model');
$modelSurvey = new Vr_model();
}
foreach($data['newhouse'] as &$value) {
$value['survey_status'] = '';
$value['can_survey'] = false;
$value['show_survey_icon'] = false;
if(intval($value['esta']) != 1){
$value['survey'] = 0;
}
if ($value['tbl'] == 'sell' && $data['limitNumGtZero'][5]['sell'] && intval($value['survey']) != 1 && intval($value['esta']) == 1 && in_array(GB_CITY, array_keys($this->surveyConfig)) && in_array(intval($value['infotype']), $this->surveyConfig[GB_CITY]['surveyInfotype']) && in_array($value['district'], $this->surveyConfig[GB_CITY]['surveyDistrict'])) {
$value['can_survey'] = true;
}
if(intval($value['survey']) == 1) {
if(GB_CITY=='nj'){
$surveyInformation = $modelSurvey->getInformation('sell', $value['id']);
$status = isset($surveyInformation[0]['status']) ? intval($surveyInformation[0]['status']) : 0;
if ($status == 3 && !empty($surveyInformation[0]['time_order']) && time() > intval($surveyInformation[0]['time_order'])) {
$status = 4;
}
if($status != 2){
$value['show_survey_icon'] = true;
}
$value['survey_status'] = isset($this->surveyStatus[$status]) ? $this->surveyStatus[$status] : '实勘未知状态';
}elseif(GB_CITY=='wh'){
$surveyInformation = $modelSurvey->getVrInfoByHouseId('sell', $value['id']);
if($surveyInformation){
$value['show_survey_icon'] = $surveyInformation['show_icon'];
$value['survey_status'] = $surveyInformation['vr_status_word'];
}
}
}
//获取房源已有套餐
if(in_array(GB_CITY,$this->openPayCitys)){
$packageData = $this->package_model->getHousePackageNew($value['id'],$value['tbl']);
if($packageData){
if(isset($packageData['leftTime'])) $value['leftTime'] = $packageData['leftTime'];
if(in_array(1,$packageData['package_types']) || in_array(2,$packageData['package_types']) || in_array(3,$packageData['package_types'])){
$value['promoting'] = 1;
}else{
$value['promoting'] = 0;
}
}
}
}
}
$data['ad3799'] = $this->getAD(3799);
$data['ad4217'] = $this->getAD(4217);
$this->load->view('index',$data);
}
/**
* 会员中心切换城市
* @author cxf
*/
public function changecity()
{
$city = $this->input->get('city');
$city = !empty($city)?$city:'nj';
header("Location:http://newrent.house365.com/user-center/switch-city?city=".$city);
die;
setcoandsess('website_jumpto_city',$city);
jumpto(USER_CENTER.'user');
}
/**
* 我的关注二手房页面
* @author cxf
*/
public function selllist()
{
$data['conf_where'] = 'selllist';
$data['title'] = '会员中心';
//删除操作
if(isset($_POST['muldel']) && $_POST['muldel']=='del')
{
$result = $this->user_model->delcollect($_POST['actionid']);
echo $result;exit;
}
//分页开始
$data['collect_num'] = $this->num_3;
$data['pagesize'] = 8;//设定每一页显示的记录数
$data['pages'] = $data['collect_num'] ? ceil($data['collect_num']/$data['pagesize']) : 0 ; //计算总页数
$data['page'] = $this->uri->segment(3) ? intval($this->uri->segment(3)) :1 ; // 获取当前页数
$data['page'] = ($data['page']>$data['pages'] && $data['pages']!=0) ? $data['pages'] : $data['page']; //判断跳转页数
$data['offset'] = $data['pagesize']*($data['page']-1); //计算记录偏移量
$data['collect'] = $this->user_model->getcollect(3,$this->user_id,$data['offset'],$data['pagesize']);
if(is_array($data['collect'])&&!empty($data['collect'])){
foreach($data['collect'] as $key=>$value){
if(GB_CITY=='nj')
{
$isChoice = $this->user_model->isCheckPriceRemind($this->user_id,$value['collect_id']);
$infofrom_data=$this->user_model->get_infofrom_by_id($value['collect_id']);
}
$data['collect'][$key]['infofrom'] =$infofrom_data[0]['infofrom'];
$data['collect'][$key]['is_remind'] = isset($isChoice[0]['status'])&&($isChoice[0]['status']==1) ? 1:0;
}
}
//获取你可能感兴趣的二手房
$data['likesell'] = $this->user_model->getlikehouse($this->user_id,'sell',4);
//BI统计 ----- start----->
$data['isa_website'] = '2,19,79';
$data['isa_city'] = GB_CITY;
$data['isa_addones'] = '';
$data['isa_url'] = 'isa.house365.com/js/analyze.js?v=2.1';
//BI统计 ----- ent----->
$this->load->view('my_attention_sell',$data);
}
/**
* 我的关注租房页面
* @author cxf
*/
public function rentlist()
{
GLOBAL $house;
$data['conf_where'] = 'selllist';
$data['title'] = '我的关注';
//删除操作
if(isset($_POST['muldel']) && $_POST['muldel']=='del')
{
$result = $this->user_model->delcollect($_POST['actionid']);
echo $result;exit;
}
//分页开始
$data['collect_num'] = $this->num_4;
$data['pagesize'] = 8;//设定每一页显示的记录数
$data['pages'] = $data['collect_num'] ? ceil($data['collect_num']/$data['pagesize']) : 0 ; //计算总页数
$data['page'] = $this->uri->segment(3) ? intval($this->uri->segment(3)) :1 ; // 获取当前页数
$data['page'] = ($data['page']>$data['pages'] && $data['pages']!=0) ? $data['pages'] : $data['page']; //判断跳转页数
$data['offset'] = $data['pagesize']*($data['page']-1); //计算记录偏移量
$data['collect'] = $this->user_model->getcollect(4,$this->user_id,$data['offset'],$data['pagesize']);
$data['collect'] = $this->user_model->getNewRentUserCollectInfo($data['collect'], 4);
$data['priceunit'] = $house['priceunit'];
//获取你可能感兴趣的租房
$data['likerent'] = $this->user_model->getlikehouse($this->user_id,'rent',4);
$this->load->view('my_attention_rent',$data);
}
/**
* 我的关注小区页面
* @author cxf
*/
public function blocklist()
{
$data['conf_where'] = 'blocklist';
$data['title'] = '我的关注';
//删除操作
if(isset($_POST['muldel']) && $_POST['muldel']=='del')
{
$result = $this->user_model->delcollect($_POST['actionid']);
echo $result;
exit;
}
//分页开始
$data['collect_num'] = $this->num_2;
$data['pagesize'] = 8;//设定每一页显示的记录数
$data['pages'] = $data['collect_num'] ? ceil($data['collect_num']/$data['pagesize']) : 0 ; //计算总页数
$data['page'] = $this->uri->segment(3) ? intval($this->uri->segment(3)) :1 ; // 获取当前页数
$data['page'] = ($data['page']>$data['pages'] && $data['pages']!=0) ? $data['pages'] : $data['page']; //判断跳转页数
$data['offset'] = $data['pagesize']*($data['page']-1); //计算记录偏移量
$data['collect'] = $this->user_model->getcollect(2,$this->user_id,$data['offset'],$data['pagesize']);
$data['collect'] = $this->user_model->getNewRentUserCollectInfo($data['collect'], 2);
//获取你可能感兴趣的小区
$data['likeblock'] = $this->user_model->getlikehouse($this->user_id,'block',4);
//BI统计 ----- start----->
$data['isa_website'] = '2,19,80';
$data['isa_city'] = GB_CITY;
$data['isa_addones'] = '';
$data['isa_url'] = 'isa.house365.com/js/analyze.js?v=2.1';
//BI统计 ----- ent----->
$this->load->view('my_attention_block',$data);
}
/**
* 我的关注学区页面
* @author xue
*/
public function schoollist()
{
$data['conf_where'] = 'schoollist';
$data['title'] = '会员中心';
//删除操作
if(isset($_POST['muldel']) && $_POST['muldel']=='del')
{
$result = $this->user_model->delcollect($_POST['actionid']);
echo $result;exit;
}
//分页开始
$data['collect_num'] = $this->num_7;
$data['pagesize'] = 8;//设定每一页显示的记录数
$data['pages'] = $data['collect_num'] ? ceil($data['collect_num']/$data['pagesize']) : 0 ; //计算总页数
$data['page'] = $this->uri->segment(3) ? intval($this->uri->segment(3)) :1 ; // 获取当前页数
$data['page'] = ($data['page']>$data['pages'] && $data['pages']!=0) ? $data['pages'] : $data['page']; //判断跳转页数
$data['offset'] = $data['pagesize']*($data['page']-1); //计算记录偏移量
$data['collect'] = $this->user_model->getCollectSchoolList(7,$this->user_id,$data['offset'],$data['pagesize']);
//获取你可能感兴趣的二手房
$data['likesell'] = $this->user_model->getLikeSchoolHouse($this->user_id);
//BI统计 ----- start----->
$data['isa_website'] = '2,19,77';
$data['isa_city'] = GB_CITY;
$data['isa_addones'] = '';
$data['isa_url'] = 'isa.house365.com/js/analyze.js?v=2.1';
//BI统计 ----- ent----->
$this->load->view('my_attention_school',$data);
}
/**
* 我的二手房关注条件页面
* @author cxf
*/
public function sell_condition()
{
$data['conf_where'] = 'sell_condition';
$data['title'] = '我的关注';
$muldel = $this->input->post('muldel');
$actionid = $this->input->post('actionid');
//删除操作
if( isset( $muldel ) && $muldel == 'del')
{
$result = $this->user_model->delcollect($actionid);
echo $result;
exit;
}
//分页开始
$data['collect_num'] = $this->num_1;
$data['pagesize'] = 5;//设定每一页显示的记录数
//计算总页数
$data['pages'] = $data['collect_num'] ? ceil($data['collect_num']/$data['pagesize']) : 0 ;
//获取当前页数
$data['page'] = $this->uri->segment(3) ? intval($this->uri->segment(3)) : 1 ;
//判断跳转页数
$data['page'] = ($data['page']>$data['pages'] && $data['pages']!=0) ? $data['pages'] : $data['page'];
//计算记录偏移量
$data['offset'] = $data['pagesize']*($data['page']-1);
$data['collect'] = $this->user_model->getcollect(1,$this->user_id,$data['offset'],$data['pagesize']);
$data['sarr'] = $this->user_model->getSeachcondStr($data['collect']);
$data['surl'] = $this->user_model->getSeachcondUrl($data['collect'], 1);
//获取你可能感兴趣的二手房
$data['likesell'] = $this->user_model->getlikehouse($this->user_id,'sell',4);
//2018-8-16加,房源特色总标签
$data['house_features'] = $this->user_model->getHouseFeatures();
//BI统计 ----- start----->
$data['isa_website'] = '2,19,78';
$data['isa_city'] = GB_CITY;
$data['isa_addones'] = '';
$data['isa_url'] = 'isa.house365.com/js/analyze.js?v=2.1';
//BI统计 ----- ent----->
$this->load->view('my_sell_condition',$data);
}
/**
* 我的关注条件页面
* @author cxf
*/
public function rent_condition()
{
global $house;
$data['conf_where'] = 'sell_condition';
$data['title'] = '我的关注';
$data['priceunit'] = $house['priceunit'];
//删除操作
if(isset($_POST['muldel']) && $_POST['muldel']=='del')
{
$result = $this->user_model->delcollect($_POST['actionid']);
echo $result;exit;
}
if(isset($_GET['zj']) && $_GET['zj']==1)
{
var_dump($house);die();
}
//分页开始
$data['collect_num'] = $this->num_5;
$data['pagesize'] = 5;//设定每一页显示的记录数
$data['pages'] = $data['collect_num'] ? ceil($data['collect_num']/$data['pagesize']) : 0 ; //计算总页数
$data['page'] = $this->uri->segment(3) ? intval($this->uri->segment(3)) :1 ; // 获取当前页数
$data['page'] = ($data['page']>$data['pages'] && $data['pages']!=0) ? $data['pages'] : $data['page']; //判断跳转页数
$data['offset'] = $data['pagesize']*($data['page']-1); //计算记录偏移量
$data['collect'] = $this->user_model->getcollect(5,$this->user_id,$data['offset'],$data['pagesize']);
$data['sarr'] = $this->user_model->getSeachcondStr($data['collect'], 'rent');
$data['surl'] = $this->user_model->getSeachcondUrl($data['collect'], 5);
//获取你可能感兴趣的租房
$data['likerent'] = $this->user_model->getlikehouse($this->user_id,'rent',4);
$this->load->view('my_rent_condition',$data);
}
/**
* 我的关注楼盘页面
* @author cxf
*/
public function officelist()
{
GLOBAL $house;
$data['conf_where'] = 'officelist';
$data['title'] = '我的关注';
//删除操作
if(isset($_POST['muldel']) && $_POST['muldel']=='del')
{
$result = $this->user_model->delcollect($_POST['actionid']);
echo $result;exit;
}
//分页开始
$data['collect_num'] = $this->num_8;
$data['pagesize'] = 8;//设定每一页显示的记录数
$data['pages'] = $data['collect_num'] ? ceil($data['collect_num']/$data['pagesize']) : 0 ; //计算总页数
$data['page'] = $this->uri->segment(3) ? intval($this->uri->segment(3)) :1 ; // 获取当前页数
$data['page'] = ($data['page']>$data['pages'] && $data['pages']!=0) ? $data['pages'] : $data['page']; //判断跳转页数
$data['offset'] = $data['pagesize']*($data['page']-1); //计算记录偏移量
$data['collect'] = $this->user_model->getcollect(8,$this->user_id,$data['offset'],$data['pagesize']);
$data['collect'] = $this->user_model->getNewRentUserCollectInfo($data['collect'], 8);
$data['priceunit'] = $house['priceunit'];
//获取你可能感兴趣的租房
$data['likerent'] = $this->user_model->getlikehouse($this->user_id,'rent',4);
$this->load->view('my_attention_office',$data);
}
/**
* 我的关注联合办公页面
* @author cxf
*/
public function brandlist()
{
GLOBAL $house;
$data['conf_where'] = 'brandlist';
$data['title'] = '我的关注';
//删除操作
if(isset($_POST['muldel']) && $_POST['muldel']=='del')
{
$result = $this->user_model->delcollect($_POST['actionid']);
echo $result;exit;
}
//分页开始
$data['collect_num'] = $this->num_9;
$data['pagesize'] = 8;//设定每一页显示的记录数
$data['pages'] = $data['collect_num'] ? ceil($data['collect_num']/$data['pagesize']) : 0 ; //计算总页数
$data['page'] = $this->uri->segment(3) ? intval($this->uri->segment(3)) :1 ; // 获取当前页数
$data['page'] = ($data['page']>$data['pages'] && $data['pages']!=0) ? $data['pages'] : $data['page']; //判断跳转页数
$data['offset'] = $data['pagesize']*($data['page']-1); //计算记录偏移量
$data['collect'] = $this->user_model->getcollect(9,$this->user_id,$data['offset'],$data['pagesize']);
$data['collect'] = $this->user_model->getNewRentUserCollectInfo($data['collect'], 9);
$data['priceunit'] = $house['priceunit'];
//获取你可能感兴趣的租房
$data['likerent'] = $this->user_model->getlikehouse($this->user_id,'rent',4);
$this->load->view('my_attention_brand',$data);
}
/**
* 用户退出
* @author cxf
*/
public function logout()
{
vbsetcookie("esfuserid","",1);
vbsetcookie("esfpassword","",1);
vbsetcookie("esfusername","",1);
vbsetcookie("esfusertelno","",1);
vbsetcookie("esfshowname","",1);
vbsetcookie("esfusercity","",1);
vbsetcookie("sso_token","",1);
setcookie("esfuserid", null, time() - 1000, "/", "house365.com");
setcookie("esfusername", null, time() - 1000, "/", "house365.com");
setcookie("esfusertelno", null, time() - 1000, "/", "house365.com");
setcookie("sso_token", null, time() - 1000, "/", "house365.com");
setcookie("PHPSESSID", null, time() - 1000, "/", "house365.com");
setcookie("PHPSESSID", null, time() - 1000, "/", "newrent.house365.com");
setcookie("newrent_yii3-session", null, time() - 1000, "/", "house365.com");
unset($_SESSION['esfuserid']);
unset($_SESSION['esfpassword']);
unset($_SESSION['esfusername']);
unset($_SESSION['esfusertelno']);
unset($_SESSION['esfusercity']);
unset($_SESSION['esfshowname']);
unset($_SESSION['sso_token']);
setcookie("sessionid", null, time() - 1000, "/", "house365.com");
setcookie("newrent_yii2-session", null, time() - 1000, "/", "house365.com");
jumpto(GB_LOGOUT_URL);exit();
if(isset($_SERVER['HTTP_REFERER']))
{
$url = substr($_SERVER['HTTP_REFERER'], 0, 35);
$url1 = substr($_SERVER['HTTP_REFERER'], 0, 40);
jumpto(GB_SELL_URL);
/*if($url==USER_CENTER.'user' || $url1==USER_CENTER.'statistic' || $url==USER_CENTER.'want')
{
//jumptotk(GB_SELL_URL,"退出成功!将返回二手房首页!",3000,'tips');
jumpto(GB_SELL_URL);
}else{
//jumptotk($_SERVER['HTTP_REFERER'],"退出成功!将返回之前的页面!",3000,'tips');
jumpto($_SERVER['HTTP_REFERER']);
}*/
}else{
//jumptotk(GB_SELL_URL,"退出成功!将返回二手房首页!",3000,'tips');
jumpto(GB_SELL_URL);
}
exit();
}
public function bind_zmxy()
{
if (!defined('OPEN_ZMXY')) {
exit('该城市暂未开通此功能!');
}
//简单防止CSRF与模拟POST访问
$data['time'] = time();
$data['token'] = md5('house365'. $data['time'] . $this->user_id); //加盐
$_SESSION[$data['token']] = 1;
$data['conf_where'] = 'bind_zmxy';
$data['title'] = '认证管理';
$data = array_merge($data,$this->realNameData());
$this->load->model('user_model');
$data['user_card_info'] = $this->user_model->getUserCardInfo($this->user_id,1);
//获取银行的配置文件
require_once(APPPATH.'config/bank.php');
$data['bank'] = $bank;
//芝麻认证信息
$zhima = $this->user_model->getCertAuth($this->user_id,1);
//银联认证
$bank_cert = $this->user_model->getCertAuth($this->user_id,2);
$data['zhima'] = $zhima;
$data['bank_cert'] = $bank_cert;
if ($_POST) {
$result = array(
'status' => 0,
'msg' => '',
'url' => ''
);
$msg = '';
$sessionToken = $_SESSION[$_POST['token']];
unset($_SESSION[$_POST['token']]);
$_POST['truename'] = iconv('utf8','gbk',$_POST['truename']);
$_POST['truename'] = addslashes($_POST['truename']);
$_POST['idno'] = addslashes($_POST['idno']);
$checkData = $this->user_model->checkIdNo($_POST['idno'], $this->user_id);
if (!$checkData['result']) {
$msg = $checkData['msg'];
}
if (empty($_POST['idno']) || empty($_POST['truename'])) {
$msg = '参数错误!';
}
//页面有效时间为5分钟
$timeFlag = time() - $_POST['time'] > 300 ? true : false;
if ($_POST['token'] != md5('house365' . $_POST['time'] . $this->user_id) || $timeFlag || $sessionToken != 1) {
$msg = '页面已过期!请重新刷新页面';
}
if (!empty($msg)) {
$result['msg'] = iconv('gbk','utf8', $msg);
exit(json_encode($result));
}
$url = $this->doBindZmxy($_POST);
$result['status'] = 1;
$result['url'] = $url;
exit(json_encode($result));
}
$this->load->view('bind_zmxy',$data);
}
private function doBindZmxy($data)
{
$userInfo = array(
'name' => iconv('gbk', 'utf8', $data['truename']),
'certNo' => $data['idno'],
'certType' => 'IDENTITY_CARD'
);
$state = $userInfo;
$state['userId'] = $this->user_id;
$bizParams = array(
'auth_code' => 'M_APPPC_CERT',
'channelType' => 'apppc',
'state' => json_encode($state)
);
//业务参数数组
$params = array(
'identity_type' => '2',
'identity_param' => json_encode($userInfo),
'biz_params' => json_encode($bizParams)
);
$this->load->library("zmop_class");
$this->zmop_class->setRsaPriKeyFile(ZMXY_PRIVATE_KEY);
$this->zmop_class->setRsaPubKeyFile(ZMXY_PUBLIC_KEY);
$sign = $this->zmop_class->getSignature($params);
$encryptData = $this->zmop_class->encrypt($params);
// 公共参数数组
$sParam = array(
'app_id' => ZMXY_APPID,
'method' => "zhima.auth.info.authorize",
'charset' => "utf-8",
'version' => "1.0",
'params' => $encryptData,
'sign' => $sign
);
$str = http_build_query($sParam);
$url = 'https://zmopenapi.zmxy.com.cn/openapi.do?' . $str;
//添加日志记录
$logData = array(
'user_id' => $this->user_id,
'truename' => $data['truename'],
'idno' => $data['idno'],
'ip' => get_ip(),
'created_time' => time()
);
$this->user_model->addAuthLog($logData);
return $url;
}
public function zmxyCallback()
{
if (!defined('OPEN_ZMXY')) {
exit('该城市暂未开通此功能!');
}
$params = $this->input->get('params');
$sign = $this->input->get('sign');
if (empty($params) || empty($sign)) {
exit('参数缺失!');
}
//含有%则urldecode
$params = strstr ( $params, '%' ) ? urldecode ( $params ) : $params;
$sign = strstr ( $sign, '%' ) ? urldecode ( $sign ) : $sign;
$this->load->library("zmop_class");
$this->zmop_class->setRsaPriKeyFile(ZMXY_PRIVATE_KEY);
$this->zmop_class->setRsaPubKeyFile(ZMXY_PUBLIC_KEY);
//解密数据
$decryptData = $this->zmop_class->decrypt($params);
//验签
$result = $this->zmop_class->verify($decryptData, $sign);
if (!$result) {
exit('签名错误!');
}
parse_str($decryptData, $paramList);
if ($paramList['success'] == 'false' && !empty($paramList['error_message'])) {
$paramList['error_message'] = iconv('utf8', 'gbk', $paramList['error_message']);
$msg = "绑定失败!失败原因:" . $paramList['error_message'];
exit($msg);
}
//更新用户数据
$state = json_decode($paramList['state'], true);
if ($this->user_id != $state['userId']) {
exit('用户信息异常!');
}
$checkData = $this->user_model->checkIdNo($state['certNo'], $this->user_id);
if (!$checkData['result']) {
exit($checkData['msg']);
}
if (empty($state['name']) || empty($state['certNo']) || empty($paramList['open_id'])) {
exit('数据异常!');
}
$updateData['truename'] = iconv('utf8', 'gbk', $state['name']);
$updateData['idno'] = $state['certNo'];
$updateData['auth_type'] = 1;
$updateData['auth_open_id'] = $paramList['open_id'];
$this->user_model->updateuser($this->user_id, $updateData);
header('Location:' . GB_CRNTER_URL . 'user/bind_zmxy/');
}
/**
* 修改个人资料
* @author cxf
*/
function edit_profile()
{
$_SESSION['token'] = md5($this->user_id);
$data['js'] = '<script type="text/javascript" src="'.USER_CENTER.'js/jquery.Jcrop.min.js"></script>';
$data['conf_where'] = 'edit_profile';
$data['title'] = '修改资料';
$data['user_detail_old'] = $this->user_model->get_userdetail($this->user_id,array('username','email','sex','birthdate'));
if($_POST)
{
if($_POST['token'] != $_SESSION['token'])
{
//echo $_POST['token']."<br/>";
//echo $_SESSION['token']."<br/>";
echo "<script> alert('请输入正确的验证');</script>";die;
}
$arr['email'] = $this->input->post('email');
$arr['sex'] = $this->input->post('sex');
$arr['birthdate'] = strtotime($this->input->post('year')."-".$this->input->post('month')."-".$this->input->post('day'));
//var_dump($arr['birthdate']);exit;
$url = GB_UPDATE_USER_INFO_BY_USER_ID_URL . '?city=nj='.GB_CITY.'&email='.$arr['email'].'&uid='.$this->user_id . '&sex=' . $arr['sex'] . '&birthdate=' . $arr['birthdate'];
$res = curl_get_contents( $url );
$res = !empty( $res ) ? json_decode( $res, 1) : array();
if ( $res['result'] != 1 ) {
echo "<script> alert(". $res['msg'] . ");</script>";die;
}
$result = $this->user_model->updateuser($this->user_id,$arr);
}
$data['user_detail'] = $this->user_model->get_userdetail($this->user_id,array('username','email','sex','birthdate','head_pic'));
//BI统计 ----- start----->
$data['isa_website'] = '2,19,83';
$data['isa_city'] = GB_CITY;
$data['isa_addones'] = '';
$data['isa_url'] = 'isa.house365.com/js/analyze.js?v=2.1';
//BI统计 ----- ent----->
$this->load->view('edit_profile',$data);
}
/**
* 修改密码
* @author cxf
*/
function edit_password()
{
$_SESSION['token'] = md5($this->user_id);
$data['js']= '<script type="text/javascript" src="'.USER_CENTER.'js/Validform_v5.3.2_ncr_min.js"></script>';
$select = array('telno');
$data['user'] = $this->user_model->get_userdetail($this->user_id,$select);
$data['conf_where'] = 'edit_password';
$data['title'] = '修改密码';
if($_POST)
{
if($_POST['token'] != $_SESSION['token'])
{
//echo $_POST['token']."<br/>";
//echo $_SESSION['token']."<br/>";
//echo "<script> alert('请输入正确的验证');</script>";die;
}
$newpassword = $this->input->post('newpassword');
$againpassword = $this->input->post('againpassword');
$password = $this->input->post('password');
if($newpassword == $againpassword)
{
$result = $this->user_model->yzloginuser($this->user_id,md5($password));
if( $result > 0 )
{
$result_pass = $this->user_model->updatepassowrdbyuid($this->user_id,$newpassword);
echo $result_pass ? 1 : 4;
exit;
}else{
echo 3;
exit;
}
}
else
{
echo 2;
exit;
}
}
$this->load->view('edit_password',$data);
}
/**
* 修改电话号码
* @author cxf
*/
function edit_telno()
{
$_SESSION['token'] = md5($this->user_id);
$data['conf_where'] = 'edit_telno';
$data['title'] = '修改手机号码';
$data['js']= '<script type="text/javascript" src="'.USER_CENTER.'js/code.js"></script><script type="text/javascript" src="'.USER_CENTER.'js/Validform_v5.3.2_ncr_min.js"></script>';
$select = array('telno');
$data['user'] = $this->user_model->get_userdetail($this->user_id,$select);
if($_POST)
{
if($_POST['token'] != $_SESSION['token'])
{
//echo $_POST['token']."<br/>";
//echo $_SESSION['token']."<br/>";
echo "<script> alert('请输入正确的验证');</script>";die;
}
$telno = $this->input->post('telnoold');
$telnonew = $this->input->post('telno');
$validcode = $this->input->post('validcode');
$kind = $this->input->post('kind');
//验证手机号是否存在
$result2 = $this->user_model->yztelnolt($telnonew);
if($result2)
{
echo 3;
exit;
}
//验证短信验证码是否正确
$result = $this->user_model->yzusersms($validcode,$telnonew,$kind);
if($result>0)
{
$result_pass = $this->user_model->updatetelnobyuid($this->user_id,$telnonew);
if($result_pass)
{
$this->user_model->SyncPhoneUserCenter($this->user_id, $telno, $telnonew);
//修改已经绑定的400号码
$this->load->model("esf_400_model");
$this->esf_400_model->update_telno($this->user_id , $telnonew ,$telno);
}
echo $result_pass ? 1 : 0;
if($result2[0]['id']>0 && $result2[0]['infofrom']==2)
{
//对原有账号进行失效操作
$this->user_model->updateuser($result2[0]['id'],array('is_use'=>0));
//对原有房源进行id修改
$this->house_model->updatehouseuid($result2[0]['id'],$this->user_id,'sell');
$this->house_model->updatehouseuid($result2[0]['id'],$this->user_id,'rent');
}
exit;
}
else
{
echo 2;
exit;
}
}
$this->load->view('edit_telno',$data);
}
/**
* 编辑头像文件
* @author cxf
*/
function edit_headfile()
{
if($this->input->post("action") == 'headfile')
{
$fileurl = common_file_upload("headfile", false, false, 340, 220);
if($fileurl)
{
echo "<script>window.parent.setHeadimgsrc('".$fileurl."');window.parent.document.getElementById('headpic').value='".$fileurl."';window.parent.jcSetImage();window.parent.changeShowPic('headShowPic');</script>";
}
else
{
echo "<script>window.parent.document.getElementById('jsUploadHeadPortrait').style.display = 'none';window.parent.document.getElementById('jsDialogE_msg').innerHTML='图片上传失败,请重试!';window.parent.openWin('jsDialogE');setTimeout(function(){window.parent.location.reload();},1000);</script>";
}
exit;
}
else if( $this->input->post("action") == 'savehead' )
{
$headpic = trim($this->input->post("headpic"));
$x = floatval($this->input->post("x"));
$y = floatval($this->input->post("y"));
$w = floatval($this->input->post("w"));
$h = floatval($this->input->post("h"));
$picfile = curl_get_contents($headpic);
if( $picfile )
{
$targ_w = $w;
$targ_h = $h;
$jpeg_quality = 100;
//FISHER 2013-6-22
//获取远程图片再裁剪处理,然后还要FTP上传到图片服务器,目前只能在本地创建临时文件,想不出其他办法了。
$filename = GB_CITY.'_'.md5($headpic).".jpg";
$cachefile = APPPATH."/cache/".$filename;
if($handle = fopen($cachefile, "wb") && $targ_w > 0 && $targ_h > 0)
{
$img_r = imagecreatefromstring($picfile);
$dst_r = ImageCreateTrueColor($targ_w, $targ_h);
imagecopyresampled($dst_r,$img_r,0,0,$x,$y,$targ_w,$targ_h,$w,$h);
imagejpeg($dst_r, $cachefile, $jpeg_quality);
@fclose($handle);
$_FILES['headfile']['nocheck'] = "house365";//uploadfile 类会检查这个文件是否是POST提交的文件,没办法啊绕过去。
$_FILES['headfile']['name'] = $filename;
$_FILES['headfile']['type'] = 'image/pjpeg';
$_FILES['headfile']['tmp_name'] = $cachefile;
$_FILES['headfile']['error'] = 0;
$_FILES['headfile']['size'] = @filesize($cachefile);
$this->load->library('uploadfile_class',array('filename'=>"headfile"));
$this->uploadfile_class->setFileType("jpg");
$this->uploadfile_class->setMaxSize(5120);
$this->uploadfile_class->setUploadType("ftp");
$this->uploadfile_class->setSaveDir("/".GB_CITY."house/");
$this->uploadfile_class->setWatermark(false);
$this->uploadfile_class->setImageCut(false);
if ($this->uploadfile_class->upload() == "success")
{
$headpicurl = $this->uploadfile_class->getSaveFileURL(); //图片地址
}
else
{
$headpicurl = "";
}
@unlink($cachefile);
if($headpicurl != "")
{
//更新用户头像
$id = $this->user_model->updateheadpic($this->user_id,$headpicurl);
if($id > 0)
{
echo "<script>window.parent.openWin('upfile-ok');</script>";
}
else
{
echo "<script>window.parent.openWin('warning');</script>";
}
}
else
{
echo "<script>window.parent.openWin('warning');</script>";
}
}
else
{
echo "<script>window.parent.openWin('warning');setTimeout(function(){window.parent.location.reload();},1000);</script>";
}
}
else
{
echo "<script>window.parent.openWin('warning');setTimeout(function(){window.parent.location.reload();},1000);</script>";
}
exit;
}
}
/**
* 我的问答
* @author cxf
*/
function myask()
{
$data['conf_where'] = 'ask';
$data['title'] = '我的问答';
//分页开始
$data['ask_num'] = $this->ask_model->getquelistnum($this->user_id);
$data['pagesize'] = 8;//设定每一页显示的记录数
$data['pages'] = $data['ask_num'] ? ceil($data['ask_num']/$data['pagesize']) : 0 ; //计算总页数
$data['page'] = $this->uri->segment(3) ? intval($this->uri->segment(3)) :1 ; // 获取当前页数
$data['page'] = ($data['page'] > $data['pages']) ? $data['pages'] : $data['page']; //判断跳转页数
$data['offset'] = $data['pagesize']*($data['page']-1); //计算记录偏移量
//获取问题列表
$data['asklist'] = $this->ask_model->getquelist($this->user_id,$data['offset'],$data['pagesize']);
$data['expertslist'] = $this->ask_model->getexperts();
//BI统计 ----- start----->
$data['isa_website'] = '2,19,99';
$data['isa_city'] = GB_CITY;
$data['isa_addones'] = '';
$data['isa_url'] = 'isa.house365.com/js/analyze.js?v=2.1';
//BI统计 ----- ent----->
//print_r($data);die;
$this->load->view('myask',$data);
}
/**
* 提问详情页跳转页
* @author cxf
*/
function qdetail($qid)
{
$arr=array('a_qid'=>$qid,'a_esta'=>1,'a_read'=>0);
$up= array('a_read'=>1);
$this->user_model->set_table('qa_answer');
$result = $this->user_model->save($arr,$up,'esfhouse');
//更新问答未读的cookie
$ask_num = $this->ask_model->getnewanswerbyuid($this->user_id);
setcoandsess('esfasknum',$ask_num);
echo '<script language="javascript">location= "'.get_questioninfo_url($qid).'";</script>';
}
/**
* 我的消息
* @author cxf
*/
function mymessage()
{
$data['conf_where'] = 'message';
$data['title'] = '我的消息';
//删除操作
if(isset($_POST['muldel']) && $_POST['muldel']=='del')
{
$result = $this->user_model->delmessage($_POST['actionid']);
echo $result;
exit;
}
//更新消息的点击状态
$this->user_model->updateannounceclick($this->user_id);
$data['num'] = $this->user_model->getmessagenumbyuid($this->user_id);
$data['pagesize'] = 8;//设定每一页显示的记录数
$data['pages'] = $data['num'] ? ceil($data['num']/$data['pagesize']) : 0 ; //计算总页数
$data['page'] = $this->uri->segment(3) ? intval($this->uri->segment(3)) :1 ; // 获取当前页数
$data['page'] = ($data['page']>$data['pages'] && $data['pages']!=0) ? $data['pages'] : $data['page']; //判断跳转页数
$data['offset'] = $data['pagesize']*($data['page']-1); //计算记录偏移量
$data['message'] = $this->user_model->getmessagebyuid($this->user_id,$data['offset'],$data['pagesize']);
//BI统计 ----- start----->
$data['isa_website'] = '2,19,82';
$data['isa_city'] = GB_CITY;
$data['isa_addones'] = '';
$data['isa_url'] = 'isa.house365.com/js/analyze.js?v=2.1';
//BI统计 ----- ent----->
$this->load->view('mymessage',$data);
}
function updateread()
{
$ids = $this->input->post("ids");
if(!empty($ids))
{
$id_arr = explode(',',$ids);
foreach($id_arr as $value)
{
$result = $this->user_model->updateannounce($value);
}
}else{
$result = $this->user_model->updateannounce($this->input->post("id"));
}
echo $result;
}
/**
* 实名认证弹窗
* @return array
*/
private function realNameData(){
$data = array();
$data['userInfo'] = $this->user_model->get_userdetail($this->user_id,array('truename','idno','auth_type','auth_open_id','passport_uid'));
// $data['imgUrl'] = 'http://mtt.house365.com/H5/pctoapp/index.php?city=nj&TFRouteType=1058&TFRouteParm=' .urlencode(urlencode('type=3&uuid='.$data['userInfo'][0]['passport_uid']));
// $data['imgUrl'] = 'http://newrent.house365.com/api/common/get-qr-code?size=144&margin=0&url='.urlencode($data['imgUrl']);
$data['imgUrl'] = '/images/downloadTFApp.png';
$data['imgUrlbg2'] = '/images/smbg2.png';
$data['imgUrlbg1'] = '/images/mybg.png';
if(GB_CITY == 'wh'){
$data['publishUrlSell'] = 'http://publish.wh.house365.com/?newWh=1&kind=1';
}else{
$data['publishUrlSell'] = "http://".GB_CITY.".publish.house365.com";
}
if(GB_CITY == 'nj'){
$data['publishUrlRent'] = "http://publish.house365.com/nj/publish";
}else if(GB_CITY == 'wh'){
$data['publishUrlRent'] = "http://publish.wh.house365.com/?newWh=1&kind=2";
}else{
$data['publishUrlRent'] = " http://".GB_CITY.".publish.house365.com/?kind=2";
}
return $data;
}
/**
* 我的房源二手房
* @author cxf
*/
function myhousesell()
{
header("Location:http://newrent.house365.com/user-center/sell-list");
die;
$data['conf_where'] = 'housesell';
$data['title'] = '我的房源';
$this->load->model('package_model');
$data['limitNumGtZero'] = $this->package_model->getLimitNumGtZero();
$data = array_merge($data,$this->realNameData());
if($_POST)
{
$id = $this->input->post('id');
$type = $this->input->post('type');
$code = $this->input->post('code');
$infotype = $this->input->post('infotype');
$payday = $this->input->post('payday');
$paytype = $this->input->post('paytype');
//推广处理
if($type =='tg'){
//更新房源状态,改为有意向
$result = $this->house_model->updatehouse($id,'sell',array('ischarge'=>'2'));
//记录客户意向
$result1 = $this->user_model->addusercharge($id, $paytype , $payday,$this->user_id );
if($result1>0)
{
//发送消息
$subject='您的房源推广申请已提交。';
$msg='您编号为"'.$id.'"的房源推广申请正在审核中,请耐心等待。';
$this->apply_class->send_systemmsg($this->user_id,$subject,$msg,1,GB_CITY);
//添加成功
echo '1';exit;
}else{
//添加失败
echo '3';exit;
}
}
//验证
if(md5($id.'house365')==$code)
{
if($type =='refresh')
{
//验证刷新可用次数
$num = $this->house_model->yzrefrshnum($this->user_id,$id,'sell');
//获取今日已刷新次数
$this->house_statistic_model->set_uid($this->user_id);
$this->house_statistic_model->set_city(GB_CITY);
$this->house_statistic_model->set_nocache(1);
$arr = $this->house_statistic_model->get_operate_list(2,$id,date("Y-m-d"));
//获得实际可刷新次数
$num = $num - count($arr);
if($num>0)
{
//更新房源刷新时间
$result = $this->house_model->updatehouse($id,'sell',array('updatetime'=>time()));
//记录刷新操作
$this->house_statistic_model->set_uid($this->user_id);
$this->house_statistic_model->set_city(GB_CITY);
$result = $this->house_statistic_model->sub_operate_log('sell' , $id , 2 );
if($result['is_ok'] == 1)
{
//发送消息
$subject='您的房源刷新成功';
$msg='您编号为"'.$id.'"房源刷新成功。如有疑问,请联系客服。';
$this->apply_class->send_systemmsg($this->user_id,$subject,$msg,1,GB_CITY);
//刷新成功
$arr1['msg'] = 1;
$arr1['num'] = $num-1;
print json_encode($arr1);exit;
}else{
//刷新失败
$arr1['msg'] = 4;
$arr1['num'] = $num;
print json_encode($arr1);exit;
}
}else{
//刷新次数不足
$arr1['msg'] = 3;
$arr1['num'] = $num;
print json_encode($arr1);exit;
}
}elseif($type =='del'){
//更新房源状态,相当于失效状态
$result = $this->house_model->updatehouse($id,'sell',array('esta'=>'2'));
//记录再发布操作
$this->house_statistic_model->set_uid($this->user_id);
$this->house_statistic_model->set_city(GB_CITY);
$result1 = $this->house_statistic_model->sub_operate_log('sell' , $id , 3 );
if($result>0)
{
//删除成功
echo '1';
exit;
}else{
//删除失败
echo '3';
exit;
}
}
elseif($type =='again_pub')
{
//更新房源状态
if(GB_CITY == 'nj')
{
if($infotype==1 or $infotype==2)
{
$expiretime = strtotime("+45 day");
}
else if($infotype==3 or $infotype==4 or $infotype==5 or $infotype==6)
{
$expiretime = strtotime("+60 day");
}
}
else
{
$expiretime = strtotime("+90 day");
}
$result = $this->house_model->republishhouse($id,'sell',array('esta'=>'1','creattime'=>time(),'updatetime'=>time(),'expiretime'=>$expiretime),GB_CITY);
//记录再发布操作
$this->house_statistic_model->set_uid($this->user_id);
$this->house_statistic_model->set_city(GB_CITY);
//$result1 = $this->house_statistic_model->sub_operate_log('sell' , $id , 5 ,1);
if($result>0)
{
$this->load->model('user_model');
//增加云信accid
$this->user_model->yunxin_accid($this->user_id);
//再发布成功
echo '1';exit;
}else{
//再发布失败
echo '3';exit;
}
}else{
//验证不通过,来源不正确
echo '2';exit;
}
}else{
//验证不通过,来源不正确
echo '2';exit;
}
}
$data['num'] = $this->house_model->gethousenumbyuid($this->user_id,'sell');
$data['pagesize'] = 8;//设定每一页显示的记录数
$data['pages'] = $data['num'] ? ceil($data['num']/$data['pagesize']) : 0 ; //计算总页数
$data['page'] = $this->uri->segment(3) ? intval($this->uri->segment(3)) :1 ; // 获取当前页数
$data['page'] = ($data['page']>$data['pages'] && $data['pages']!=0) ? $data['pages'] : $data['page']; //判断跳转页数
$data['offset'] = $data['pagesize']*($data['page']-1); //计算记录偏移量
if(GB_CITY=='nj' || GB_CITY=='wh')
{
$data['house_array'] = $this->house_model->gethousebyuid($this->user_id,'sell',array('id','address','buildarea','price','updatetime','creattime','esta','ischarge','pic1','district','streetid','blockshowname','infotype','room','hall','fitment','buildarea','ischarge','telno','floor ','subfloor','totalfloor','survey'),$data['offset'],$data['pagesize']);
}
else
{
$data['house_array'] = $this->house_model->gethousebyuid($this->user_id,'sell',array('id','address','buildarea','price','updatetime','creattime','esta','ischarge','pic1','district','streetid','blockshowname','infotype','room','hall','fitment','buildarea','ischarge','telno','floor ','subfloor','totalfloor'),$data['offset'],$data['pagesize']);
}
if (is_array($data['house_array'])) {
if(GB_CITY=='nj'){
$this->load->model('survey_model');
$modelSurvey = new Survey_model();
}elseif(GB_CITY == 'wh'){
$this->load->model('vr_model');
$modelSurvey = new Vr_model();
}
foreach($data['house_array'] as &$value) {
$value['survey_status'] = '';
$value['can_survey'] = false;
$value['show_survey_icon'] = false;
if(intval($value['esta']) != 1){
$value['survey'] = 0;
}
if ($data['limitNumGtZero'][5]['sell'] && intval($value['survey']) != 1 && intval($value['esta']) == 1 && in_array(GB_CITY, array_keys($this->surveyConfig)) && in_array(intval($value['infotype']), $this->surveyConfig[GB_CITY]['surveyInfotype']) && in_array($value['district'], $this->surveyConfig[GB_CITY]['surveyDistrict'])) {
$value['can_survey'] = true;
}
if(intval($value['survey']) == 1) {
if(GB_CITY=='nj'){
$surveyInformation = $modelSurvey->getInformation('sell', $value['id']);
$status = isset($surveyInformation[0]['status']) ? intval($surveyInformation[0]['status']) : 0;
if ($status == 3 && !empty($surveyInformation[0]['time_order']) && time() > intval($surveyInformation[0]['time_order'])) {
$status = 4;
}
if($status != 2){
$value['show_survey_icon'] = true;
}
$value['survey_status'] = isset($this->surveyStatus[$status]) ? $this->surveyStatus[$status] : '实勘未知状态';
}elseif(GB_CITY=='wh'){
$surveyInformation = $modelSurvey->getVrInfoByHouseId('sell', $value['id']);
if($surveyInformation){
$value['show_survey_icon'] = $surveyInformation['show_icon'];
$value['survey_status'] = $surveyInformation['vr_status_word'];
}
}
}
//获取房源已有套餐
if(in_array(GB_CITY,$this->openPayCitys)){
$packageData = $this->package_model->getHousePackageNew($value['id'],'sell');
if($packageData){
if(isset($packageData['leftTime'])) $value['leftTime'] = $packageData['leftTime'];
if(in_array(1,$packageData['package_types']) || in_array(2,$packageData['package_types']) || in_array(3,$packageData['package_types'])){
$value['promoting'] = 1;
}else{
$value['promoting'] = 0;
}
}
}
}
}
//中奖通知 5.25-8.31
$data['is_win'] = $this->_get_is_win();
//BI统计 ----- start----->
$data['isa_website'] = '2,19,72';
$data['isa_city'] = GB_CITY;
$data['isa_addones'] = '';
$data['isa_url'] = 'isa.house365.com/js/analyze.js?v=2.1';
//BI统计 ----- ent----->
$data['userInfo'] = $this->user_model->get_userdetail($this->user_id,array('truename','idno','auth_type','auth_open_id','passport_uid','bank_type'));
$this->load->view('myhousesell',$data);
}
/**
* 我的房源二手房
* @author cxf
*/
function myhouserent()
{
header("Location:http://newrent.house365.com/user-center/rent-list");
die;
global $house;
$data['conf_where'] = 'houserent';
$data['title'] = '我的房源';
$data = array_merge($data,$this->realNameData());
$this->load->model('package_model');
$data['limitNumGtZero'] = $this->package_model->getLimitNumGtZero();
if($_POST)
{
$id = $this->input->post('id');
$type = $this->input->post('type');
$code = $this->input->post('code');
$infotype = $this->input->post('infotype');
$payday = $this->input->post('payday');
$paytype = $this->input->post('paytype');
//推广处理
if($type =='tg'){
//更新房源状态,改为有意向
$result = $this->house_model->updatehouse($id,'rent',array('ischarge'=>'2'));
//记录客户意向
$result1 = $this->user_model->addusercharge($id, $paytype , $payday,$this->user_id,'rent' );
if($result1>0)
{
//发送消息
$subject='您的房源推广申请已提交。';
$msg='您编号为"'.$id.'"的房源推广申请正在审核中,请耐心等待。';
$this->apply_class->send_systemmsg($this->user_id,$subject,$msg,1,GB_CITY);
//添加成功
echo '1';exit;
}else{
//添加失败
echo '3';exit;
}
}
//验证
if(md5($id.'house365')==$code)
{
if($type =='refresh')
{
//验证刷新可用次数
$num = $this->house_model->yzrefrshnum($this->user_id,$id,'rent');
//获取今日已刷新次数
$this->house_statistic_model->set_uid($this->user_id);
$this->house_statistic_model->set_city(GB_CITY);
$this->house_statistic_model->set_nocache(1);
$arr = $this->house_statistic_model->get_operate_list(2,$id,date("Y-m-d"));
//获得实际可刷新次数
$num = $num - count($arr);
if($num>0)
{
//更新房源刷新时间
$result = $this->house_model->updatehouse($id,'rent',array('updatetime'=>time()));
if(empty($result))
{
$arr1['msg'] = 4;
$arr1['num'] = $num;
print json_encode($arr1);exit;
}
//记录刷新操作
$this->house_statistic_model->set_uid($this->user_id);
$this->house_statistic_model->set_city(GB_CITY);
$result = $this->house_statistic_model->sub_operate_log('rent' , $id , 2,1);
if($result['is_ok'] == 1)
{
//发送消息
$subject='您的房源刷新成功';
$msg='您编号为"'.$id.'"房源刷新成功。如有疑问,请联系客服。';
$this->apply_class->send_systemmsg($this->user_id,$subject,$msg,1,GB_CITY);
//刷新成功
$arr1['msg'] = 1;
$arr1['num'] = $num-1;
print json_encode($arr1);exit;
}else{
//刷新失败
$arr1['msg'] = 4;
$arr1['num'] = $num;
print json_encode($arr1);exit;
}
}else{
//刷新次数不足
$arr1['msg'] = 3;
$arr1['num'] = $num;
print json_encode($arr1);exit;
}
}elseif($type =='del'){
//更新房源状态
$result = $this->house_model->updatehouse($id,'rent',array('esta'=>2));
//记录再发布操作
$this->house_statistic_model->set_uid($this->user_id);
$this->house_statistic_model->set_city(GB_CITY);
$result1 = $this->house_statistic_model->sub_operate_log('rent' , $id , 3 );
if($result>0)
{
//通知爱租哪
if(GB_CITY == 'nj' || GB_CITY == 'hf')
{
$houseData = $this->house_model->gethousebywhere(array('id' => $id),'rent',array('iszhizu'),1);
if(!empty($houseData) && $houseData[0]['iszhizu'] == '1')
{
$url = 'http://mtapi.house365.com/?method=zhizu.ApiRent_syncEsf2AznStatus&city='.GB_CITY.'&id='.$id.'&esta=2&uid='.$this->user_id;
curl_get_contents($url);
}
}
//删除成功
echo '1';exit;
}
else
{
//删除失败
echo '3';exit;
}
}
elseif($type =='again_pub')
{
//更新房源状态
if(GB_CITY == 'nj')
{
if($infotype == 1 or $infotype == 2)
{
$expiretime = strtotime("+35 day");
}
else if($infotype==3 or $infotype==4 or $infotype==5 or $infotype==6)
{
$expiretime = strtotime("+60 day");
}
}
else
{
$expiretime = strtotime("+90 day");
}
$result = $this->house_model->republishhouse($id,'rent',array('esta'=>1,'creattime'=>time(),'updatetime'=>time(),'expiretime'=>$expiretime),GB_CITY);
//记录再发布操作
$this->house_statistic_model->set_uid($this->user_id);
$this->house_statistic_model->set_city(GB_CITY);
$result1 = $this->house_statistic_model->sub_operate_log('rent' , $id , 5 );
if($result>0)
{
//通知爱租哪
if(GB_CITY == 'nj' || GB_CITY == 'hf')
{
$houseData = $this->house_model->gethousebywhere(array('id' => $id),'rent',array('iszhizu'),1);
if(!empty($houseData) && $houseData[0]['iszhizu'] == '1')
{
$url = 'http://mtapi.house365.com/?method=zhizu.ApiRent_syncEsf2AznStatus&city='.GB_CITY.'&id='.$id.'&esta=1&uid='.$this->user_id;
curl_get_contents($url);
}
}
$this->load->model('user_model');
//增加云信accid
$this->user_model->yunxin_accid($this->user_id);
//再发布成功
echo '1';exit;
}else{
//再发布失败
echo '3';exit;
}
}else{
//验证不通过,来源不正确
echo '2';exit;
}
}else{
//验证不通过,来源不正确
echo '2';exit;
}
}
$data['num'] = $this->house_model->gethousenumbyuid($this->user_id,'rent');
$data['pagesize'] = 8;//设定每一页显示的记录数
$data['pages'] = $data['num'] ? ceil($data['num']/$data['pagesize']) : 0 ; //计算总页数
$data['page'] = $this->uri->segment(3) ? intval($this->uri->segment(3)) :1 ; // 获取当前页数
$data['page'] = ($data['page']>$data['pages'] && $data['pages']!=0) ? $data['pages'] : $data['page']; //判断跳转页数
$data['offset'] = $data['pagesize']*($data['page']-1); //计算记录偏移量
//获取房源
$data['house_array'] = $this->house_model->gethousebyuid($this->user_id,'rent',array('id','address','buildarea','price','updatetime','creattime','esta','ischarge','pic1','district','streetid','blockshowname','infotype','room','hall','fitment','buildarea','priceunit','ischarge','telno','floor ','subfloor','totalfloor'),$data['offset'],$data['pagesize']);
//获取房源已有套餐
if(in_array(GB_CITY,$this->openPayCitys)){
foreach($data['house_array'] as &$value) {
$packageData = $this->package_model->getHousePackageNew($value['id'],'rent');
if($packageData){
if(isset($packageData['leftTime'])) $value['leftTime'] = $packageData['leftTime'];
if(in_array(1,$packageData['package_types']) || in_array(2,$packageData['package_types']) || in_array(3,$packageData['package_types'])){
$value['promoting'] = 1;
}else{
$value['promoting'] = 0;
}
}
}
}
$data['priceunit'] = $house['priceunit'];
//中奖通知 5.25-8.31
$data['is_win'] = $this->_get_is_win();
//BI统计 ----- start----->
$data['isa_website'] = '2,19,73';
$data['isa_city'] = GB_CITY;
$data['isa_addones'] = '';
$data['isa_url'] = 'isa.house365.com/js/analyze.js?v=2.1';
//BI统计 ----- ent----->
$data['userInfo'] = $this->user_model->get_userdetail($this->user_id,array('truename','idno','auth_type','auth_open_id','passport_uid','bank_type'));
$this->load->view('myhouserent',$data);
}
/**
* 获取当前会员是否获取奖品
*
*/
private function _get_is_win()
{
$result = array();
if(GB_CITY == 'nj' && false)
{
$time = time();
$start_date = mktime(0,0,0,5,25,date('Y'));
$end_date = mktime(23,59,59,12,23,date('Y'));
if($start_date <= $time && $time <= $end_date)
{
$user_data = $this->user_model->get_user_data($this->user_id);
if(!empty($user_data) && !empty($user_data['telno']))
{
$result = $this->user_model->check_is_win($this->user_id,$user_data['telno'],$start_date,$end_date);
}
}
}
return $result;
}
//价格提醒处理ajax
function price_remind_ajax(){
// error_reporting(7);
// ini_set("display_errors",true);
$this->load->model("user_model");
$houseid = $this->input->post('houseid');
$type = $this->input->post('type');
$flag = $this->input->post('flag');
$priceRemindNum = $this->user_model->getPriceRemindNum($this->user_id);
if($priceRemindNum>=5&&$flag==1){//满4条提示
$result = 3;
}else{
$isChoice = $this->user_model->isCheckPriceRemind($this->user_id,$houseid);
//var_dump($isChoice);exit();
if(is_array($isChoice)){
if(empty($isChoice)&&$flag==1){
$result = $this->user_model->addPriceRemind($houseid,$this->user_id);
//echo "444";
}elseif($isChoice[0]['status']==1&&$flag==0){
$result = $this->user_model->updatePrcieRemind($houseid,$this->user_id,0);
}elseif($isChoice[0]['status']==0&&$flag==1){
$result = $this->user_model->updatePrcieRemind($houseid,$this->user_id,1);
}
}
}
echo $result = $result ? $result :0;
}
public function pay(){
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept');
if(GB_CITY != 'nj' && GB_CITY != 'wh'){
return $this->jump(USER_CENTER,'该城市暂未开通此功能!',3000,'warning');
}
//定义支持的支付类型
$payTypeArr = array('wxpay');
//获取房源属性
$packageId = intval($this->input->post('package_id',true));
$houseId = intval($this->input->post('house_id',true));
$tbl = addslashes($this->input->post('tbl',true));
$packageType = intval($this->input->post('package_type',true));
$packageKeyword = intval($this->input->post('package_keyword',true));
$day = intval($this->input->post('day_'.$packageType,true));
$payType = addslashes($this->input->post('pay_type',true));
// 是否使用优惠券
$use_coupon = intval($this->input->post('use_coupon',true));
// 优惠券ID
$coupon_id = intval($this->input->post('coupon_id',true));
$from_url = $this->input->post('from_url',true);
if(empty($packageId) || empty($houseId) || empty($tbl) || empty($packageType) || (!in_array($packageType,array(4,5)) && empty($day)) || empty($payType) || !in_array($payType,$payTypeArr)){
return $this->jump(USER_CENTER,'参数缺失',3000,'warning');
}
$searchArr['id'] = $houseId;
$searchArr['uid'] = $this->user_id;
$searchArr['infofrom'] = 1;
$searchArr['esta'] = 1;
//获取房源信息
$houseData = $this->house_model->gethousebywhere($searchArr,$tbl,array('id,infofrom,infotype,district,telno'),1);
if(empty($houseData)){
return $this->jump(USER_CENTER,'房源状态异常',3000,'warning');
}
//获取联系人手机号
if(GB_CITY == 'nj' && $houseData[0]['infofrom'] == 1){
$tbl_ext = $tbl == 'rent' ? 'rent_ext' : 'sell_ext';
$telno = $this->house_model->getHouseTel($houseId,$tbl_ext);
if($telno){
$houseData[0]['telno'] = $telno;
}
}
$infoType = $houseData[0]['infotype'] == 1 ? 1 : 2;
//加载套餐model类
$this->load->model("package_model");
$packageData = $this->package_model->getDetailById($packageId);
if(empty($packageData)){
return $this->jump(USER_CENTER,'套餐状态异常',3000,'warning');
}
//价格数据
$packageData['package_desc'] = unserialize($packageData['package_desc']);
foreach($packageData['package_desc'] as $item){
if($packageType == 4){
$price = $originalPrice = floatval($item['price']);
}else if($packageType == 5){
if($item['property_type'] == $infoType){
$price = $originalPrice = floatval($item['price']);
//处理折扣
if(isset($item['discount']) && $item['discount'] >0){
$price = $originalPrice = $this->pirceDiscount($price,$item['discount']);
}
}
}else{
if($item['property_type'] == $infoType && $item['day'] == $day){
$price = $originalPrice = floatval($item['price']);
if(GB_CITY == 'wh' && $packageType == 2){
//处理折扣
if(isset($item['discount']) && $item['discount'] >0){
$price = $originalPrice = $this->pirceDiscount($price,$item['discount']);
}
}
// 列表套餐8折券使用 20200507
// 优惠券修改为 6折
// if( GB_CITY == 'nj' && $packageType == 2 && $tbl == 'rent'){
// //
// $checkbox_status = 0;
// // 检查是否有可用的优惠券,如果有则使用,如果无,则跳转提示
// $userInfoData = $this->user_model->getuserdetail($this->user_id);
// $passport_uid = $userInfoData ? $userInfoData['passport_uid'] : 0;
//
// // 测试数据
// $couponUserIdArr = array('1785149','3367096','4112782');
// if( in_array($this->user_id,$couponUserIdArr) ){
// $price = 0.05;
// }
//
// if( isset($use_coupon) && $use_coupon == 1){
//
// $check_coupon = $this->rent_coupon_model->checkCoupon($passport_uid);
// if( !$check_coupon ){
// $from_url = $from_url ? $from_url : USER_CENTER;
// return $this->jumpNew($from_url,'已有待支付订单,勿重复下单!<br/>请30分钟后再试。',3000,'warning');
// }
// $checkbox_status = 1;
// // 列表优先套餐8折
// // 修改为6折 20200927
// $price = sprintf("%.2f",$price * 0.6);
// // 锁定半小时
// $this->rent_coupon_model->lockCoupon($passport_uid);
//
//
// }
//
// // 设置8折优惠券的选中状态
// $this->rent_coupon_model->setCheckbox($passport_uid,$checkbox_status);
//
// }
}
}
}
// 使用优惠券
if ( GB_CITY == 'nj' ) {
if( isset( $use_coupon ) && $use_coupon == 1 ) {
$couponRes = $this->user_model->checkCoupon( $this->user_id, $coupon_id, $price, $packageType );
if ( isset( $couponRes['result'] ) && $couponRes['result'] == 1 ) {
$price = $price - $couponRes['data']['coupon_price'] ;
}
}
}
$userIdArr = array(4112782,5355879,1729793,4449390,6264549);
if(in_array($this->user_id,$userIdArr)){
$price = $price * 0.01;
}
// 付款方式
$payType = $price <= 0 ? 'zeroyuanpay' : $payType;
//校验参数正确性
// if($packageType != $packageData['package_type'] || empty($price) || $price <= 0){
// return $this->jump(USER_CENTER,'套餐价格数据异常',3000,'warning');
// }
if($packageType != $packageData['package_type']){
return $this->jump(USER_CENTER,'套餐数据异常',3000,'warning');
}
if($packageType == 1 && ( $packageKeyword != $packageData['package_keyword'] || $packageKeyword <= 0 ) ){
return $this->jump(USER_CENTER,'套餐关键词异常',3000,'warning');
}
//首页推荐需要限制数量
if($packageType == 1){
//已售出和已锁定的套餐数量
$count = $this->package_model->getPackageNum($packageKeyword,$tbl);
if($count >= $packageData['package_num']){
return $this->jump(USER_CENTER,'套餐已售完',3000,'warning');
}
}
//wh实勘限制购买数量
if($packageType == 5){
//城市限制
if (!in_array($houseData[0]['district'], $this->surveyConfig[GB_CITY]['surveyDistrict'])) {
return $this->jump(USER_CENTER,'所在区域实勘服务暂未开通',3000,'warning');
}
$this->load->model('vr_model');
$countVr = $this->vr_model->getVrApplyNowNum(1,3); //sell 个人房源
$countOrder = $this->package_model->getPackageOrderNumByType($packageType,$tbl); //未支付有效订单
if( $countVr+$countOrder >= $packageData['package_num']){
return $this->jump(USER_CENTER,'套餐已售完',3000,'warning');
}
}
//首页推荐和列表排序在有效期内不能同时购买(南京租房除外 修改日期2020/3/4)
//获取该房源的套餐状态
$housePackage = $this->package_model->getHousePackage($houseId,$tbl);
//获取禁止的套餐数组
$banHousePackage = array();
if(!empty($housePackage)){
foreach($housePackage as $k =>$v){
if($v == 1 || $v == 2){
if(GB_CITY == 'nj' && $tbl == 'rent'){
$banHousePackage[] = $v;
}else{
$banHousePackage[] = 1;
$banHousePackage[] = 2;
}
}
if($v == 3){
$banHousePackage[] = 3;
}
}
}
if(in_array($packageData['package_type'],$banHousePackage)){
return $this->jump(USER_CENTER,'请勿重复购买套餐',3000,'warning');
}
//创建订单
$tblArr = array('sell' => 1 ,'rent' => 2);
$tableId = $tblArr[$tbl];
$orderData = array();
$orderData['transaction_id'] = $this->package_model->getTransactionId( $packageType );
$orderData['user_id'] = $this->user_id;
$orderData['house_type'] = $tableId;
$orderData['house_id'] = $houseId;
$orderData['house_tel'] = $houseData[0]['telno'];
$orderData['package_id'] = $packageId;
$orderData['package_type'] = $packageType;
if($packageType == 1){
$orderData['package_keyword'] = $packageKeyword;
}
// 优惠券字段
if ( isset( $couponRes['result'] ) && $couponRes['result'] == 1 ) {
$orderData['coupon_name'] = isset( $couponRes['data']['name'] ) ? iconv('utf-8','gbk',$couponRes['data']['name']) : 0;
$orderData['coupon_price'] = isset( $couponRes['data']['coupon_price'] ) ? $couponRes['data']['coupon_price'] : 0;
$orderData['coupon_id'] = isset( $couponRes['data']['id'] ) ? $couponRes['data']['id'] : 0;
}
$orderData['package_days'] = $day;
$orderData['price'] = $price;
$orderData['create_time'] = time();
$orderData['pay_type'] = $payType;
$orderData['source'] = 1;
$orderData['ip'] = get_ip();
$orderId = $this->package_model->createOrder($orderData);
$orderData['id'] = $orderId;
//极小概率出现的订单号重复处理
if($orderId <= 0){
return $this->jump(USER_CENTER ,'订单创建失败',3000,'warning');
}
// 使用优惠券
if ( GB_CITY == 'nj' ){
if( isset( $use_coupon ) && $use_coupon == 1 ) {
$this->user_model->useCoupon( $orderData['transaction_id'], $this->user_id, $coupon_id, $originalPrice, $packageType );
// 0元支付
if ( $price <= 0 ) {
//支付成功后的操作
$result = $this->package_model->payFinish($orderData, array('transaction_id' => $this->package_model->getPaymentTransactionId( $packageType )));
if (GB_CITY == 'nj') {
$this->package_model->sendMsg( $orderData );
}
$data['orderData'] = $orderData;
$data['title'] = '0元支付';
$this->load->view('zero_yuan_pay', $data);
return;
}
}
}
$data = $this->getWxPayCodeByHouse365($orderId);
if($data['status'] != 1){
return $this->jump(USER_CENTER , $data['msg'],3000,'warning');
}
$data['orderData'] = $orderData;
$data['title'] = '微信支付';
$this->load->view('wxpay',$data);
}
/**
* 折扣
* @param $price
* @param $discount
*/
private function pirceDiscount($price,$discount){
return $price*$discount/10;
}
/**
* 向house365支付中台查询订单状态
* @param $transactionId
* @return string
*/
public function queryOrder($transactionId){
$data = array('status' => 0);
if(!in_array(GB_CITY,$this->openPayCitys)){
echo json_encode($data);exit;
}
$this->load->model("package_model");
$curlData = array();
$curlData['serviceCode'] = 'pay';
$curlData['serviceName'] = 'queryOrder';
$curlData['actId'] = $this->openPayCitysActId[GB_CITY];
$curlData['tradeNo'] = $transactionId;
$curlData['sign'] = $this->package_model->makeSign($curlData);
$url = 'https://pay.house365.com/house365-pay-web/rest/interface';
$result = SendDataByCurl($url,$curlData);
$result = json_decode($result,true);
if(!empty($result['status'])){
$result['status'] = iconv('utf-8','gbk',$result['status']);
}
if(!empty($result) && $result['result'] == 'SUCCESS' && $result['status'] == '支付成功'){
$data['status'] = 1;
//测试环境无法回调的处理
//$orderInfo = $this->package_model->getOrderInfoByTransactionId($transactionId);
//$this->package_model->payFinish($orderInfo);
}
echo json_encode($data);exit;
}
/**
* 根据订单ID生成微信支付二维码
* @param $orderId 订单ID
* @return array
*/
private function getWxPayCodeByHouse365($orderId){
//加载套餐model类
$data['status'] = 0;
$this->load->model("package_model");
$packageData = $this->package_model->getOrderInfoById($orderId);
if(empty($packageData) || $packageData['order_status'] == 0 || $packageData['pay_status'] == 1){
$msg = '订单信息异常';
$data['msg'] = $msg;
return $data;
}
$transaction_id = $packageData['transaction_id'];
$price = $packageData['price'];
$notifyUrl = 'http://user.house365.com/esf_center_api/notify?city='.GB_CITY;
//$price = 0.01;
//$notifyUrl = 'http://esfadmin.house365.com/test.php';
$packageTypeName = $this->package_model->getPackageTypeName($packageData['package_type']);
$subject = '个人房源增值服务-' . GB_CITY . '-' .$packageTypeName;
//拼接数组
$curlData = array();
$curlData['serviceCode'] = 'pay';
$curlData['serviceName'] = 'createAPPReceiptOrder';
//活动标识
switch (GB_CITY){
case 'nj' :
$curlData['actId'] = '57';
break;
case 'wh' :
$curlData['actId'] = '82';
break;
}
$curlData['tradeNo'] = $transaction_id;
$curlData['version'] = '1.0';
$curlData['notifyUrl'] = $notifyUrl;
$curlData['amount'] = $price * 100;
$curlData['city'] = GB_CITY;
$curlData['wechatTradeType'] = 1;
$curlData['subject'] = iconv('gbk','utf-8',$subject);
//订单过期时间为30分钟,考虑到网络延迟加上10S
$curlData['timeExpire'] = date("YmdHis", time() + 30 * 60 + 10);
$IpHostAllow =explode('.',get_ip());
if($IpHostAllow[0] == '192' && ($_COOKIE['is_test_wh'] == 'test' || (isset($_COOKIE['esfuserid']) && $_COOKIE['esfuserid'] == 2640088))){
$orderInfo = $this->package_model->getOrderInfoByTransactionId($transaction_id);
$this->package_model->payFinish($orderInfo);
$data['status'] = 1;
$data['msg'] = "支付完成!";
$data['is_test'] = 1;
return $data;
}
$curlData['sign'] = $this->package_model->makeSign($curlData);
$url = 'https://pay.house365.com/house365-pay-web/rest/interface';
$result = SendDataByCurl($url,$curlData);
$result = json_decode($result,true);
if(!empty($result['payParams']) && !is_array($result['payParams'])){
$result['payParams'] = json_decode($result['payParams'],true);
}
if ( isset( $_COOKIE['zj'] ) && $_COOKIE['zj'] == 1 ) {
$curlData['subject'] = iconv('utf-8','gbk',$curlData['subject']);
var_dump($curlData);die();
}
if( empty($result) || $result['result'] != 'SUCCESS' || empty($result['payParams']['code_url']) ){
$msg = !empty($result['payParams']['msg']) ? $result['payParams']['msg'] : $result['msg'];
//若未返回错误信息则返回默认错误信息
$msg = !empty($msg) ? iconv('utf-8','gbk',$msg): '支付参数有误';
$data['msg'] = $msg;
return $data;
}
$data['status'] = 1;
//此处调用微信支付的生成二维码接口,后期如果微信接口不能访问请自行用qrcode生成二维码
// $data['url'] = 'http://paysdk.weixin.qq.com/example/qrcode.php?data='.urlencode($result['payParams']['code_url']);
// $data['url'] = 'http://qr.liantu.com/api.php?text='.urlencode($result['payParams']['code_url']);
$data['url'] = 'http://newrent.house365.com/api/common/get-qr-code?size=298&margin=0&url='.urlencode($result['payParams']['code_url']);
return $data;
}
/**
* 根据房源获取该房源可以购买的套餐
* @param int $houseId 房源ID
* @param string $tbl sell/rent
* @param string $type promote:房源推广 refresh:房源刷新
*/
public function getPersonalHousePackage($houseId , $tbl = 'sell' , $type = 'promote')
{
if(GB_CITY != 'nj' && GB_CITY != 'wh'){
return;
}
$this->load->model('package_model');
$packageData = $this->package_model->getPackageByHouseId($houseId,$tbl);
$promoteData = array();
$refreshData = array();
$surveyData = array();
foreach($packageData as $key => $value){
if($value['package_type'] == 1 && GB_CITY == 'nj'){
$promoteData[] = $value;
}
if($value['package_type'] == 2 ){
$promoteData[] = $value;
}
if($value['package_type'] == 3 || $value['package_type'] == 4){
$refreshData[] = $value;
}
if($value['package_type'] == 5 && GB_CITY == 'wh'){
$surveyData[] = $value;
}
}
if($type == 'promote'){
echo json_encode($promoteData);
}
if($type == 'refresh'){
echo json_encode($refreshData);
}
if($type == 'survey'){
echo json_encode($surveyData);
}
}
public function orderInvoice($orderId = '0'){
if(GB_CITY != 'nj' && GB_CITY != 'wh'){
return $this->jump(USER_CENTER ,'当前城市暂未开通此功能',3000,'warning');
}
//获取订单状态
$this->load->model("package_model");
$orderData = $this->package_model->getOrderInfoById($orderId);
//校验订单状态
if($orderData['user_id'] != $this->user_id || $orderData['order_status'] != 1 ){
return $this->jump(USER_CENTER ,'订单数据异常',3000,'warning');
}
//获取发票是否创建
$invoiceData = $this->package_model->getOrderInvoice($orderId);
if(!empty($invoiceData)){
return $this->jump(USER_CENTER ,'发票已经创建',3000,'warning');
}
//获取用户最新的发票信息
$oldInvoice = $this->package_model->getOrderInvoiceByUserId($this->user_id);
//领取方式
$oldInvoice['send_type_show'] = 1;
$oldInvoice['send_type_more_show'] = $oldInvoice['send_type'] == 1 ? 1 : 0;
if ( GB_CITY == 'nj') {
if ( $oldInvoice['user_type'] == 2 ) {
$oldInvoice['send_type_show'] = 0;
}
if ( $data['send_type_show'] == 1 && $data['send_type'] == 1 ) {
$oldInvoice['send_type_more_show'] = 1;
} else {
$oldInvoice['send_type_more_show'] = 0;
}
}
$oldInvoice['pic'] = !empty($oldInvoice['pic']) ? explode(',', $oldInvoice['pic']) : array();
$data['oldInvoice'] = $oldInvoice;
$data['orderData'] = $orderData;
$data['title'] = '发票在线填写';
$this->load->model("tel_model");
$data['telno_config'] = $this->tel_model->getTelInfoByType(tel_model::TYPE3);
$data['address_config'] = isset($this->address[GB_CITY]) ? $this->address[GB_CITY] : '';
$this->load->view('order_invoice',$data);
}
public function createOrderInvoice(){
if(GB_CITY != 'nj' && GB_CITY != 'wh'){
return;
}
$orderId = intval($this->input->post('order_id',true));
$userType = intval($this->input->post('user_type',true));
$type = intval($this->input->post('type',true));
$username = addslashes($this->input->post('username',true));
$identityCard = addslashes($this->input->post('identity_card',true));
$invoiceTitle = addslashes($this->input->post('invoice_title',true));
$invoiceNumber = addslashes($this->input->post('invoice_number',true));
$bank = addslashes($this->input->post('bank',true));
$phone = addslashes($this->input->post('phone',true));
$address = addslashes($this->input->post('address',true));
$sendType = addslashes($this->input->post('send_type',true));
$bankAccount = addslashes($this->input->post('bank_account',true));
$mailingUsername = addslashes($this->input->post('mailing_username',true));
$mailingAddress = addslashes($this->input->post('mailing_address',true));
$mailingPhone = addslashes($this->input->post('mailing_phone',true));
$telno = addslashes($this->input->post('telno',true));
$email = addslashes($this->input->post('email',true));
// $picArr = $this->input->post('p_filename',true);
$picArr = $this->input->post('file_name',true);
//参数判断
$type = $type > 0 ? $type : 1;
if(empty($orderId) || empty($type) || empty($userType)){
return $this->jump(USER_CENTER ,'参数缺失',3000,'warning');
}
if ( GB_CITY != 'nj' && empty($sendType)) {
return $this->jump(USER_CENTER ,'参数缺失',3000,'warning');
}
if ( GB_CITY == 'nj' && !( $userType == 2 && $type == 2 ) ) {
if ( empty($telno) || empty($email) ) {
return $this->jump(USER_CENTER, '参数缺失', 3000, 'warning');
}
}
if($userType == 1 && $type == 2){
return $this->jump(USER_CENTER ,'参数错误',3000,'warning');
}
if($userType == 1 && ( empty($username) || empty($identityCard))){
return $this->jump(USER_CENTER ,'参数缺失',3000,'warning');
}
if($userType == 2 && ( empty($invoiceTitle) || empty($invoiceNumber) ) ){
return $this->jump(USER_CENTER ,'参数缺失',3000,'warning');
}
if($type == 2 && ( empty($bank) || empty($phone) || empty($address) || empty($bankAccount) || empty($picArr)) ){
return $this->jump(USER_CENTER ,'参数缺失',3000,'warning');
}
if($sendType == 1 && GB_CITY != 'nj' && ( empty($mailingUsername) || empty($mailingAddress) || empty($mailingPhone) ) ){
return $this->jump(USER_CENTER ,'参数缺失',3000,'warning');
}
//获取订单状态
$this->load->model("package_model");
$orderData = $this->package_model->getOrderInfoById($orderId);
//校验订单状态
if($orderData['user_id'] != $this->user_id || $orderData['pay_status'] != 1 || $orderData['order_status'] != 1 ){
return $this->jump(USER_CENTER ,'订单数据异常',3000,'warning');
}
//获取发票是否创建
$invoiceData = $this->package_model->getOrderInvoice($orderId);
if(!empty($invoiceData)){
return $this->jump(USER_CENTER ,'发票已经创建',3000,'warning');
}
$data = array();
$data['order_id'] = $orderId;
$data['type'] = $type;
$data['price'] = $orderData['price'];
$data['send_type'] = $sendType;
$data['user_type'] = $userType;
if ( GB_CITY == 'nj' ) {
$data['invoice_class'] = $type == 2 ? 2 : 3;//电子发票
$data['send_type'] = $sendType > 0 ? $sendType : 1;
$data['want_invoice'] = 1;
$data['telno'] = $telno;
$data['email'] = $email;
}
if($userType == 1){
$data['username'] = $username;
$data['identity_card'] = $identityCard;
}
if($userType == 2){
$data['invoice_title'] = $invoiceTitle;
$data['invoice_number'] = $invoiceNumber;
$pic = addslashes( implode(',',$picArr) );
$data['pic'] = $pic;
}
if($type == 2){
$data['bank'] = $bank;
$data['bank_account'] = $bankAccount;
$data['phone'] = $phone;
$data['address'] = $address;
}
if($sendType == 1){
$data['mailing_username'] = $mailingUsername;
$data['mailing_address'] = $mailingAddress;
$data['mailing_phone'] = $mailingPhone;
}
$invoiceId = $this->package_model->createOrderInvoice($data);
if($invoiceId <= 0){
return $this->jump(USER_CENTER ,'发票生成失败',3000,'warning');
}
//获取推广信息
$promoteData = $this->package_model->getPromoteByOrderId($orderId);
$promoteId = $promoteData['id'];
$updateData = array();
$updateData['invoice_id'] = $invoiceId;
$updateData['invoice_status'] = 0;
$where = array();
$where['id'] = $promoteId;
$this->package_model->updatePromote($updateData, $where);
return $this->jump(USER_CENTER);
}
/**
* form表单提示信息 2017-12-18
* @param string $url
* @param string $msg
* @param string $time
* @param string $type
*/
private function jump( $url = 'user.house365.com' , $msg = '提交成功', $time ='3000', $type = 'success'){
$data['msg'] = $msg;
$data['url'] = $url;
$data['time'] = $time;
$data['type'] = $type;
$this->load->view('form_alert',$data);
}
// 20200610
private function jumpNew( $url = 'user.house365.com' , $msg = '提交成功', $time ='3000', $type = 'success'){
$data['msg'] = $msg;
$data['url'] = $url;
$data['time'] = $time;
$data['type'] = $type;
$this->load->view('form_alert_new',$data);
}
//我的订单
public function myorder(){
$data['conf_where'] = 'myorder';
$data['title'] = '我的订单';
$data['pagesize'] = 10;//记录每页的条数
$data['page'] = $this->uri->segment(3) ? intval($this->uri->segment(3)) :1 ; // 获取当前页数
$data['totalsize'] = $this->user_model->myorder_count($this->user_id);//记录总数
$data['totalpage'] = ceil($data['totalsize']/$data['pagesize']);
$orderdata = $this->user_model->myorder_list($this->user_id,$data['page'],$data['pagesize']);
$invoiceUrlArr = $this->user_model->getInvoiceUrlArr( $orderdata );
$data['orders'] = $orderdata;
$data['invoice_url_arr'] = $invoiceUrlArr;
$this->load->view('myorder',$data);
}
//图形验证码
public function imageCode(){
$this->user_model->imageCode();
}
//图形验证码验证
public function imageCodeVerify(){
$re = $this->user_model->imageCodeVerify();
$re['msg'] = iconv('gbk','utf-8',$re['msg']);
echo json_encode($re);die;
}
//银行卡实名认证
public function bankCertify(){
$re = $this->user_model->bankCertify();
$re['msg'] = iconv('gbk','utf-8',$re['msg']);
if(!empty($re['data']['truename'])){
$re['data']['truename'] = iconv('gbk','utf-8',$re['data']['truename']);
}
echo json_encode($re);die;
}
}
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class User extends MY_Controller
{
/**
* Survey
* @author Candison <www.kandisheng.com>
*/
private $surveyConfig = array(
'nj' => array(
'surveyInfotype' => array(1,'1'),
'surveyDistrict' => array('雨花台区'),
),
'wh' => array(
'surveyInfotype' => array(1,2,3,4,5,6,'1','2','3','4','5','6'),
'surveyDistrict' => array('镜湖区', '鸠江区', '弋江区', '三山区'),
),
);
/**
* 开通支付的城市
* @var array
*/
private $openPayCitys = array(
'nj','wh'
);
/**
* 支付中台活动id
* @var array
*/
private $openPayCitysActId = array(
'nj' => 57,
'wh' => 82,
);
private $surveyStatus = array(
0 => '实勘未知状态',
1 => '实勘审核中',
2 => '实勘不通过',
3 => '实勘已预约',
4 => '实勘处理中',
5 => '实勘已上传',
6 => '实勘已取消'
);
private $address = array(
'nj' => '南京市建邺区云龙山路99号江苏省建大厦B幢6楼信息中心;(地铁10号线中胜站下2A出口,向东300米',
'wh' => '芜湖市镜湖区绿地新都会C座7层 365淘房二手房运营部',
);
function __construct()
{
parent::__construct();
$this->load->model("user_model");
$this->load->model("broker_model");
$this->load->model("pic_model");
$this->load->model("block_model");
$this->load->model("ask_model");
$this->load->model("house_model");
$this->load->model("house_statistic_model");
// 租房9折优惠券 20200507添加
$this->load->model('rent_coupon_model');
$this->load->library("user_class");
$this->load->library("apply_class");
$this->user_id = checklogin();
if( $this->user_id <= 0 )
{
jumpto( USER_CENTER.'login');
exit();
}
//关注各项数量
$this->num_1 = $this->user_model->getusercollect($this->user_id,1);
$this->num_2 = $this->user_model->getusercollect($this->user_id,2);
$this->num_3 = $this->user_model->getusercollect($this->user_id,3);
$this->num_4 = $this->user_model->getusercollect($this->user_id,4);
$this->num_5 = $this->user_model->getusercollect($this->user_id,5);
$this->num_7 = $this->user_model->getusercollect($this->user_id,7);
}
private function getAD($id=0, $width=0, $height=0)
{
/*
$databaseHost = '172.17.1.5';
$databasePort = '3306';
$databaseName = 'njhouse';
$databaseAccount = 'root';
$databasePassword = 'idontcare';
$databaseCharset = 'gbk';
// Connect
$mysql = mysql_connect(sprintf('%s:%s', $databaseHost, $databasePort), $databaseAccount, $databasePassword);
if($mysql === false){
return $defaultString;
}
// Query
$sql = sprintf('select id,filetype,width,height,href,src from news_ad where id="%s" limit 1', $id);
$result = mysql_db_query($databaseName, $sql, $mysql);
if($result === false){
return $defaultString;
}
$data = mysql_fetch_row($result);
if($data === false){
return $defaultString;
}
*/
// Config
$defaultString = '';
$adInterfaceBaseURL = 'http://adadmin.house365.com/api/ad/sort_ads.php';
// Get Data
$adInterfaceURL = sprintf('%s?city=%s&id=%s', $adInterfaceBaseURL, GB_CITY, $id);
$result = curl_get_contents($adInterfaceURL);
if(empty($result)){
return $defaultString;
}
$data = unserialize($result);
if(!isset($data[0])){
return $defaultString;
}
$data = $data[0];
// HTML
if(intval($width) == 0 && intval($height) == 0){
$width = $data['width'];
$height = $data['height'];
}
if($data['filetype'] == 'i'){
if(empty($data['href'])){
return sprintf('<img target="_blank" src="%s" width="%s" height="%s" border="0">', $data['src'], $width, $height);
}
return sprintf('<a target="_blank" href="%s"><img target="_blank" src="%s" width="%s" height="%s" border="0"></a>', $data['link'], $data['src'], $width, $height);
}
if($data['filetype'] == 'f'){
return sprintf('<embed src="%s" quality="high" width="%s" height="%s" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent">', $data['src'], $width, $height);
}
return $defaultString;
}
/**
* 用户中心首页
* @author cxf
*/
public function index()
{
global $house;
header("Location:http://newrent.house365.com/user-center/index");
die;
$data['conf_where'] = 'index';
$data['title'] = '会员中心';
$data['priceunit'] = $house['priceunit'];
$data['sell_num'] = $this->house_model->gethousenumbyuid($this->user_id,'sell',1);
$data['rent_num'] = $this->house_model->gethousenumbyuid($this->user_id,'rent',1);
$data['want_num'] = $this->user_model->get_rent_wantnum_by_uid($this->user_id,1);
$data['buy_num'] = $this->user_model->get_buynum_by_uid($this->user_id,1);
$data['user_detail'] = $this->user_model->get_userdetail($this->user_id,array('email','telno','auth_type','bank_type'));
$data = array_merge($data,$this->realNameData());
//获取最新2条房源
$newhouse = $this->user_model->newhouse( $this->user_id , 2 );
$data['newhouse'] = $newhouse;
$count_newhouse =count($newhouse);
$active_num =0;
$active_sell_num =0;
for($i=0;$i<$count_newhouse;$i++)
{
if($newhouse[$i]['esta']==1)
{
if($newhouse[$i]['tbl']=='sell')
{
$active_sell_num++;
}
$active_num++;
}
}
$sell_collect_house = $this->user_model->getcollect(3,$this->user_id,0,8); //网友关注的二手房房源
$rent_collect_house = $this->user_model->getcollect(4,$this->user_id,0,8); //网友关注的租房房源
$sell_collect_block = $this->user_model->getcollect(2,$this->user_id,0,8); //网友关注的小区
$data['sell_collect_house'] = $sell_collect_house;
$data['rent_collect_house'] = $rent_collect_house;
$data['sell_collect_block'] = $sell_collect_block;
//获取你可能感兴趣的二手房
$data['likesell'] = $this->user_model->getlikehousebyrule($active_num,$active_sell_num,$newhouse,$sell_collect_house,$sell_collect_block,$this->user_id,'sell',$active_sell_num,4);
//获取你可能感兴趣的租房
$data['likerent'] = $this->user_model->getlikehousebyrule($active_num,$active_sell_num,$newhouse,$rent_collect_house,$sell_collect_block,$this->user_id,'rent',$active_sell_num,4);
//获取你可能感兴趣的小区
$data['likeblock'] = $this->user_model->getlikehousebyrule($active_num,$active_sell_num,$newhouse,$sell_collect_house,$sell_collect_block,$this->user_id,'block',4);
//中奖通知 5.25-8.31
$data['is_win'] = $this->_get_is_win();
//BI统计 ----- start----->
$data['isa_website'] = '2,19,46';
$data['isa_city'] = GB_CITY;
$data['isa_addones'] = '';
$data['isa_url'] = 'isa.house365.com/js/analyze.js?v=2.1';
$this->load->model('package_model');
$data['limitNumGtZero'] = $this->package_model->getLimitNumGtZero();
//BI统计 ----- ent----->
/**
* Survey
* @author Candison <www.kandisheng.com>
*/
if (is_array($data['newhouse'])) {
if(GB_CITY=='nj'){
$this->load->model('survey_model');
$modelSurvey = new Survey_model();
}elseif(GB_CITY == 'wh'){
$this->load->model('vr_model');
$modelSurvey = new Vr_model();
}
foreach($data['newhouse'] as &$value) {
$value['survey_status'] = '';
$value['can_survey'] = false;
$value['show_survey_icon'] = false;
if(intval($value['esta']) != 1){
$value['survey'] = 0;
}
if ($value['tbl'] == 'sell' && $data['limitNumGtZero'][5]['sell'] && intval($value['survey']) != 1 && intval($value['esta']) == 1 && in_array(GB_CITY, array_keys($this->surveyConfig)) && in_array(intval($value['infotype']), $this->surveyConfig[GB_CITY]['surveyInfotype']) && in_array($value['district'], $this->surveyConfig[GB_CITY]['surveyDistrict'])) {
$value['can_survey'] = true;
}
if(intval($value['survey']) == 1) {
if(GB_CITY=='nj'){
$surveyInformation = $modelSurvey->getInformation('sell', $value['id']);
$status = isset($surveyInformation[0]['status']) ? intval($surveyInformation[0]['status']) : 0;
if ($status == 3 && !empty($surveyInformation[0]['time_order']) && time() > intval($surveyInformation[0]['time_order'])) {
$status = 4;
}
if($status != 2){
$value['show_survey_icon'] = true;
}
$value['survey_status'] = isset($this->surveyStatus[$status]) ? $this->surveyStatus[$status] : '实勘未知状态';
}elseif(GB_CITY=='wh'){
$surveyInformation = $modelSurvey->getVrInfoByHouseId('sell', $value['id']);
if($surveyInformation){
$value['show_survey_icon'] = $surveyInformation['show_icon'];
$value['survey_status'] = $surveyInformation['vr_status_word'];
}
}
}
//获取房源已有套餐
if(in_array(GB_CITY,$this->openPayCitys)){
$packageData = $this->package_model->getHousePackageNew($value['id'],$value['tbl']);
if($packageData){
if(isset($packageData['leftTime'])) $value['leftTime'] = $packageData['leftTime'];
if(in_array(1,$packageData['package_types']) || in_array(2,$packageData['package_types']) || in_array(3,$packageData['package_types'])){
$value['promoting'] = 1;
}else{
$value['promoting'] = 0;
}
}
}
}
}
$data['ad3799'] = $this->getAD(3799);
$data['ad4217'] = $this->getAD(4217);
$this->load->view('index',$data);
}
/**
* 会员中心切换城市
* @author cxf
*/
public function changecity()
{
$city = $this->input->get('city');
$city = !empty($city)?$city:'nj';
header("Location:http://newrent.house365.com/user-center/switch-city?city=".$city);
die;
setcoandsess('website_jumpto_city',$city);
jumpto(USER_CENTER.'user');
}
/**
* 我的关注二手房页面
* @author cxf
*/
public function selllist()
{
$data['conf_where'] = 'selllist';
$data['title'] = '会员中心';
//删除操作
if(isset($_POST['muldel']) && $_POST['muldel']=='del')
{
$result = $this->user_model->delcollect($_POST['actionid']);
echo $result;exit;
}
//分页开始
$data['collect_num'] = $this->num_3;
$data['pagesize'] = 8;//设定每一页显示的记录数
$data['pages'] = $data['collect_num'] ? ceil($data['collect_num']/$data['pagesize']) : 0 ; //计算总页数
$data['page'] = $this->uri->segment(3) ? intval($this->uri->segment(3)) :1 ; // 获取当前页数
$data['page'] = ($data['page']>$data['pages'] && $data['pages']!=0) ? $data['pages'] : $data['page']; //判断跳转页数
$data['offset'] = $data['pagesize']*($data['page']-1); //计算记录偏移量
$data['collect'] = $this->user_model->getcollect(3,$this->user_id,$data['offset'],$data['pagesize']);
if(is_array($data['collect'])&&!empty($data['collect'])){
foreach($data['collect'] as $key=>$value){
if(GB_CITY=='nj')
{
$isChoice = $this->user_model->isCheckPriceRemind($this->user_id,$value['collect_id']);
$infofrom_data=$this->user_model->get_infofrom_by_id($value['collect_id']);
}
$data['collect'][$key]['infofrom'] =$infofrom_data[0]['infofrom'];
$data['collect'][$key]['is_remind'] = isset($isChoice[0]['status'])&&($isChoice[0]['status']==1) ? 1:0;
}
}
//获取你可能感兴趣的二手房
$data['likesell'] = $this->user_model->getlikehouse($this->user_id,'sell',4);
//BI统计 ----- start----->
$data['isa_website'] = '2,19,79';
$data['isa_city'] = GB_CITY;
$data['isa_addones'] = '';
$data['isa_url'] = 'isa.house365.com/js/analyze.js?v=2.1';
//BI统计 ----- ent----->
$this->load->view('my_attention_sell',$data);
}
/**
* 我的关注租房页面
* @author cxf
*/
public function rentlist()
{
GLOBAL $house;
$data['conf_where'] = 'selllist';
$data['title'] = '我的关注';
//删除操作
if(isset($_POST['muldel']) && $_POST['muldel']=='del')
{
$result = $this->user_model->delcollect($_POST['actionid']);
echo $result;exit;
}
//分页开始
$data['collect_num'] = $this->num_4;
$data['pagesize'] = 8;//设定每一页显示的记录数
$data['pages'] = $data['collect_num'] ? ceil($data['collect_num']/$data['pagesize']) : 0 ; //计算总页数
$data['page'] = $this->uri->segment(3) ? intval($this->uri->segment(3)) :1 ; // 获取当前页数
$data['page'] = ($data['page']>$data['pages'] && $data['pages']!=0) ? $data['pages'] : $data['page']; //判断跳转页数
$data['offset'] = $data['pagesize']*($data['page']-1); //计算记录偏移量
$data['collect'] = $this->user_model->getcollect(4,$this->user_id,$data['offset'],$data['pagesize']);
$data['priceunit'] = $house['priceunit'];
//获取你可能感兴趣的租房
$data['likerent'] = $this->user_model->getlikehouse($this->user_id,'rent',4);
$this->load->view('my_attention_rent',$data);
}
/**
* 我的关注小区页面
* @author cxf
*/
public function blocklist()
{
$data['conf_where'] = 'blocklist';
$data['title'] = '我的关注';
//删除操作
if(isset($_POST['muldel']) && $_POST['muldel']=='del')
{
$result = $this->user_model->delcollect($_POST['actionid']);
echo $result;
exit;
}
//分页开始
$data['collect_num'] = $this->num_2;
$data['pagesize'] = 8;//设定每一页显示的记录数
$data['pages'] = $data['collect_num'] ? ceil($data['collect_num']/$data['pagesize']) : 0 ; //计算总页数
$data['page'] = $this->uri->segment(3) ? intval($this->uri->segment(3)) :1 ; // 获取当前页数
$data['page'] = ($data['page']>$data['pages'] && $data['pages']!=0) ? $data['pages'] : $data['page']; //判断跳转页数
$data['offset'] = $data['pagesize']*($data['page']-1); //计算记录偏移量
$data['collect'] = $this->user_model->getcollect(2,$this->user_id,$data['offset'],$data['pagesize']);
//获取你可能感兴趣的小区
$data['likeblock'] = $this->user_model->getlikehouse($this->user_id,'block',4);
//BI统计 ----- start----->
$data['isa_website'] = '2,19,80';
$data['isa_city'] = GB_CITY;
$data['isa_addones'] = '';
$data['isa_url'] = 'isa.house365.com/js/analyze.js?v=2.1';
//BI统计 ----- ent----->
$this->load->view('my_attention_block',$data);
}
/**
* 我的关注学区页面
* @author xue
*/
public function schoollist()
{
$data['conf_where'] = 'schoollist';
$data['title'] = '会员中心';
//删除操作
if(isset($_POST['muldel']) && $_POST['muldel']=='del')
{
$result = $this->user_model->delcollect($_POST['actionid']);
echo $result;exit;
}
//分页开始
$data['collect_num'] = $this->num_7;
$data['pagesize'] = 8;//设定每一页显示的记录数
$data['pages'] = $data['collect_num'] ? ceil($data['collect_num']/$data['pagesize']) : 0 ; //计算总页数
$data['page'] = $this->uri->segment(3) ? intval($this->uri->segment(3)) :1 ; // 获取当前页数
$data['page'] = ($data['page']>$data['pages'] && $data['pages']!=0) ? $data['pages'] : $data['page']; //判断跳转页数
$data['offset'] = $data['pagesize']*($data['page']-1); //计算记录偏移量
$data['collect'] = $this->user_model->getCollectSchoolList(7,$this->user_id,$data['offset'],$data['pagesize']);
//获取你可能感兴趣的二手房
$data['likesell'] = $this->user_model->getLikeSchoolHouse($this->user_id);
//BI统计 ----- start----->
$data['isa_website'] = '2,19,77';
$data['isa_city'] = GB_CITY;
$data['isa_addones'] = '';
$data['isa_url'] = 'isa.house365.com/js/analyze.js?v=2.1';
//BI统计 ----- ent----->
$this->load->view('my_attention_school',$data);
}
/**
* 我的二手房关注条件页面
* @author cxf
*/
public function sell_condition()
{
$data['conf_where'] = 'sell_condition';
$data['title'] = '我的关注';
$muldel = $this->input->post('muldel');
$actionid = $this->input->post('actionid');
//删除操作
if( isset( $muldel ) && $muldel == 'del')
{
$result = $this->user_model->delcollect($actionid);
echo $result;
exit;
}
//分页开始
$data['collect_num'] = $this->num_1;
$data['pagesize'] = 5;//设定每一页显示的记录数
//计算总页数
$data['pages'] = $data['collect_num'] ? ceil($data['collect_num']/$data['pagesize']) : 0 ;
//获取当前页数
$data['page'] = $this->uri->segment(3) ? intval($this->uri->segment(3)) : 1 ;
//判断跳转页数
$data['page'] = ($data['page']>$data['pages'] && $data['pages']!=0) ? $data['pages'] : $data['page'];
//计算记录偏移量
$data['offset'] = $data['pagesize']*($data['page']-1);
$data['collect'] = $this->user_model->getcollect(1,$this->user_id,$data['offset'],$data['pagesize']);
$data['sarr'] = $this->user_model->getSeachcondStr($data['collect']);
$data['surl'] = $this->user_model->getSeachcondUrl($data['collect'], 1);
//获取你可能感兴趣的二手房
$data['likesell'] = $this->user_model->getlikehouse($this->user_id,'sell',4);
//2018-8-16加,房源特色总标签
$data['house_features'] = $this->user_model->getHouseFeatures();
//BI统计 ----- start----->
$data['isa_website'] = '2,19,78';
$data['isa_city'] = GB_CITY;
$data['isa_addones'] = '';
$data['isa_url'] = 'isa.house365.com/js/analyze.js?v=2.1';
//BI统计 ----- ent----->
$this->load->view('my_sell_condition',$data);
}
/**
* 我的关注条件页面
* @author cxf
*/
public function rent_condition()
{
global $house;
$data['conf_where'] = 'sell_condition';
$data['title'] = '我的关注';
$data['priceunit'] = $house['priceunit'];
//删除操作
if(isset($_POST['muldel']) && $_POST['muldel']=='del')
{
$result = $this->user_model->delcollect($_POST['actionid']);
echo $result;exit;
}
//分页开始
$data['collect_num'] = $this->num_5;
$data['pagesize'] = 5;//设定每一页显示的记录数
$data['pages'] = $data['collect_num'] ? ceil($data['collect_num']/$data['pagesize']) : 0 ; //计算总页数
$data['page'] = $this->uri->segment(3) ? intval($this->uri->segment(3)) :1 ; // 获取当前页数
$data['page'] = ($data['page']>$data['pages'] && $data['pages']!=0) ? $data['pages'] : $data['page']; //判断跳转页数
$data['offset'] = $data['pagesize']*($data['page']-1); //计算记录偏移量
$data['collect'] = $this->user_model->getcollect(5,$this->user_id,$data['offset'],$data['pagesize']);
$data['sarr'] = $this->user_model->getSeachcondStr($data['collect']);
$data['surl'] = $this->user_model->getSeachcondUrl($data['collect'], 5);
//获取你可能感兴趣的租房
$data['likerent'] = $this->user_model->getlikehouse($this->user_id,'rent',4);
$this->load->view('my_rent_condition',$data);
}
/**
* 用户退出
* @author cxf
*/
public function logout()
{
vbsetcookie("esfuserid","",1);
vbsetcookie("esfpassword","",1);
vbsetcookie("esfusername","",1);
vbsetcookie("esfusertelno","",1);
vbsetcookie("esfshowname","",1);
vbsetcookie("esfusercity","",1);
vbsetcookie("sso_token","",1);
setcookie("esfuserid", null, time() - 1000, "/", "house365.com");
setcookie("esfusername", null, time() - 1000, "/", "house365.com");
setcookie("esfusertelno", null, time() - 1000, "/", "house365.com");
setcookie("sso_token", null, time() - 1000, "/", "house365.com");
setcookie("PHPSESSID", null, time() - 1000, "/", "house365.com");
setcookie("PHPSESSID", null, time() - 1000, "/", "newrent.house365.com");
unset($_SESSION['esfuserid']);
unset($_SESSION['esfpassword']);
unset($_SESSION['esfusername']);
unset($_SESSION['esfusertelno']);
unset($_SESSION['esfusercity']);
unset($_SESSION['esfshowname']);
unset($_SESSION['sso_token']);
setcookie("sessionid", null, time() - 1000, "/", "house365.com");
setcookie("newrent_yii2-session", null, time() - 1000, "/", "house365.com");
if(isset($_SERVER['HTTP_REFERER']))
{
$url = substr($_SERVER['HTTP_REFERER'], 0, 35);
$url1 = substr($_SERVER['HTTP_REFERER'], 0, 40);
if($url==USER_CENTER.'user' || $url1==USER_CENTER.'statistic' || $url==USER_CENTER.'want')
{
//jumptotk(GB_SELL_URL,"退出成功!将返回二手房首页!",3000,'tips');
jumpto(GB_SELL_URL);
}else{
//jumptotk($_SERVER['HTTP_REFERER'],"退出成功!将返回之前的页面!",3000,'tips');
jumpto($_SERVER['HTTP_REFERER']);
}
}else{
//jumptotk(GB_SELL_URL,"退出成功!将返回二手房首页!",3000,'tips');
jumpto(GB_SELL_URL);
}
exit();
}
public function bind_zmxy()
{
if (!defined('OPEN_ZMXY')) {
exit('该城市暂未开通此功能!');
}
//简单防止CSRF与模拟POST访问
$data['time'] = time();
$data['token'] = md5('house365'. $data['time'] . $this->user_id); //加盐
$_SESSION[$data['token']] = 1;
$data['conf_where'] = 'bind_zmxy';
$data['title'] = '认证管理';
$data = array_merge($data,$this->realNameData());
$this->load->model('user_model');
$data['user_card_info'] = $this->user_model->getUserCardInfo($this->user_id,1);
//获取银行的配置文件
require_once(APPPATH.'config/bank.php');
$data['bank'] = $bank;
//芝麻认证信息
$zhima = $this->user_model->getCertAuth($this->user_id,1);
//银联认证
$bank_cert = $this->user_model->getCertAuth($this->user_id,2);
$data['zhima'] = $zhima;
$data['bank_cert'] = $bank_cert;
if ($_POST) {
$result = array(
'status' => 0,
'msg' => '',
'url' => ''
);
$msg = '';
$sessionToken = $_SESSION[$_POST['token']];
unset($_SESSION[$_POST['token']]);
$_POST['truename'] = iconv('utf8','gbk',$_POST['truename']);
$_POST['truename'] = addslashes($_POST['truename']);
$_POST['idno'] = addslashes($_POST['idno']);
$checkData = $this->user_model->checkIdNo($_POST['idno'], $this->user_id);
if (!$checkData['result']) {
$msg = $checkData['msg'];
}
if (empty($_POST['idno']) || empty($_POST['truename'])) {
$msg = '参数错误!';
}
//页面有效时间为5分钟
$timeFlag = time() - $_POST['time'] > 300 ? true : false;
if ($_POST['token'] != md5('house365' . $_POST['time'] . $this->user_id) || $timeFlag || $sessionToken != 1) {
$msg = '页面已过期!请重新刷新页面';
}
if (!empty($msg)) {
$result['msg'] = iconv('gbk','utf8', $msg);
exit(json_encode($result));
}
$url = $this->doBindZmxy($_POST);
$result['status'] = 1;
$result['url'] = $url;
exit(json_encode($result));
}
$this->load->view('bind_zmxy',$data);
}
private function doBindZmxy($data)
{
$userInfo = array(
'name' => iconv('gbk', 'utf8', $data['truename']),
'certNo' => $data['idno'],
'certType' => 'IDENTITY_CARD'
);
$state = $userInfo;
$state['userId'] = $this->user_id;
$bizParams = array(
'auth_code' => 'M_APPPC_CERT',
'channelType' => 'apppc',
'state' => json_encode($state)
);
//业务参数数组
$params = array(
'identity_type' => '2',
'identity_param' => json_encode($userInfo),
'biz_params' => json_encode($bizParams)
);
$this->load->library("zmop_class");
$this->zmop_class->setRsaPriKeyFile(ZMXY_PRIVATE_KEY);
$this->zmop_class->setRsaPubKeyFile(ZMXY_PUBLIC_KEY);
$sign = $this->zmop_class->getSignature($params);
$encryptData = $this->zmop_class->encrypt($params);
// 公共参数数组
$sParam = array(
'app_id' => ZMXY_APPID,
'method' => "zhima.auth.info.authorize",
'charset' => "utf-8",
'version' => "1.0",
'params' => $encryptData,
'sign' => $sign
);
$str = http_build_query($sParam);
$url = 'https://zmopenapi.zmxy.com.cn/openapi.do?' . $str;
//添加日志记录
$logData = array(
'user_id' => $this->user_id,
'truename' => $data['truename'],
'idno' => $data['idno'],
'ip' => get_ip(),
'created_time' => time()
);
$this->user_model->addAuthLog($logData);
return $url;
}
public function zmxyCallback()
{
if (!defined('OPEN_ZMXY')) {
exit('该城市暂未开通此功能!');
}
$params = $this->input->get('params');
$sign = $this->input->get('sign');
if (empty($params) || empty($sign)) {
exit('参数缺失!');
}
//含有%则urldecode
$params = strstr ( $params, '%' ) ? urldecode ( $params ) : $params;
$sign = strstr ( $sign, '%' ) ? urldecode ( $sign ) : $sign;
$this->load->library("zmop_class");
$this->zmop_class->setRsaPriKeyFile(ZMXY_PRIVATE_KEY);
$this->zmop_class->setRsaPubKeyFile(ZMXY_PUBLIC_KEY);
//解密数据
$decryptData = $this->zmop_class->decrypt($params);
//验签
$result = $this->zmop_class->verify($decryptData, $sign);
if (!$result) {
exit('签名错误!');
}
parse_str($decryptData, $paramList);
if ($paramList['success'] == 'false' && !empty($paramList['error_message'])) {
$paramList['error_message'] = iconv('utf8', 'gbk', $paramList['error_message']);
$msg = "绑定失败!失败原因:" . $paramList['error_message'];
exit($msg);
}
//更新用户数据
$state = json_decode($paramList['state'], true);
if ($this->user_id != $state['userId']) {
exit('用户信息异常!');
}
$checkData = $this->user_model->checkIdNo($state['certNo'], $this->user_id);
if (!$checkData['result']) {
exit($checkData['msg']);
}
if (empty($state['name']) || empty($state['certNo']) || empty($paramList['open_id'])) {
exit('数据异常!');
}
$updateData['truename'] = iconv('utf8', 'gbk', $state['name']);
$updateData['idno'] = $state['certNo'];
$updateData['auth_type'] = 1;
$updateData['auth_open_id'] = $paramList['open_id'];
$this->user_model->updateuser($this->user_id, $updateData);
header('Location:' . GB_CRNTER_URL . 'user/bind_zmxy/');
}
/**
* 修改个人资料
* @author cxf
*/
function edit_profile()
{
$_SESSION['token'] = md5($this->user_id);
$data['js'] = '<script type="text/javascript" src="'.USER_CENTER.'js/jquery.Jcrop.min.js"></script>';
$data['conf_where'] = 'edit_profile';
$data['title'] = '修改资料';
$data['user_detail_old'] = $this->user_model->get_userdetail($this->user_id,array('username','email','sex','birthdate'));
if($_POST)
{
if($_POST['token'] != $_SESSION['token'])
{
//echo $_POST['token']."<br/>";
//echo $_SESSION['token']."<br/>";
echo "<script> alert('请输入正确的验证');</script>";die;
}
$arr['email'] = $this->input->post('email');
$arr['sex'] = $this->input->post('sex');
$arr['birthdate'] = strtotime($this->input->post('year')."-".$this->input->post('month')."-".$this->input->post('day'));
//var_dump($arr['birthdate']);exit;
$result = $this->user_model->updateuser($this->user_id,$arr);
}
$data['user_detail'] = $this->user_model->get_userdetail($this->user_id,array('username','email','sex','birthdate','head_pic'));
//BI统计 ----- start----->
$data['isa_website'] = '2,19,83';
$data['isa_city'] = GB_CITY;
$data['isa_addones'] = '';
$data['isa_url'] = 'isa.house365.com/js/analyze.js?v=2.1';
//BI统计 ----- ent----->
$this->load->view('edit_profile',$data);
}
/**
* 修改密码
* @author cxf
*/
function edit_password()
{
$_SESSION['token'] = md5($this->user_id);
$data['js']= '<script type="text/javascript" src="'.USER_CENTER.'js/Validform_v5.3.2_ncr_min.js"></script>';
$select = array('telno');
$data['user'] = $this->user_model->get_userdetail($this->user_id,$select);
$data['conf_where'] = 'edit_password';
$data['title'] = '修改密码';
if($_POST)
{
if($_POST['token'] != $_SESSION['token'])
{
//echo $_POST['token']."<br/>";
//echo $_SESSION['token']."<br/>";
//echo "<script> alert('请输入正确的验证');</script>";die;
}
$newpassword = $this->input->post('newpassword');
$againpassword = $this->input->post('againpassword');
$password = $this->input->post('password');
if($newpassword == $againpassword)
{
$result = $this->user_model->yzloginuser($this->user_id,md5($password));
if( $result > 0 )
{
$result_pass = $this->user_model->updatepassowrdbyuid($this->user_id,$newpassword);
echo $result_pass ? 1 : 4;
exit;
}else{
echo 3;
exit;
}
}
else
{
echo 2;
exit;
}
}
$this->load->view('edit_password',$data);
}
/**
* 修改电话号码
* @author cxf
*/
function edit_telno()
{
$_SESSION['token'] = md5($this->user_id);
$data['conf_where'] = 'edit_telno';
$data['title'] = '修改手机号码';
$data['js']= '<script type="text/javascript" src="'.USER_CENTER.'js/code.js"></script><script type="text/javascript" src="'.USER_CENTER.'js/Validform_v5.3.2_ncr_min.js"></script>';
$select = array('telno');
$data['user'] = $this->user_model->get_userdetail($this->user_id,$select);
if($_POST)
{
if($_POST['token'] != $_SESSION['token'])
{
//echo $_POST['token']."<br/>";
//echo $_SESSION['token']."<br/>";
echo "<script> alert('请输入正确的验证');</script>";die;
}
$telno = $this->input->post('telnoold');
$telnonew = $this->input->post('telno');
$validcode = $this->input->post('validcode');
$kind = $this->input->post('kind');
//验证手机号是否存在
$result2 = $this->user_model->yztelnolt($telnonew);
if($result2)
{
echo 3;
exit;
}
//验证短信验证码是否正确
$result = $this->user_model->yzusersms($validcode,$telnonew,$kind);
if($result>0)
{
$result_pass = $this->user_model->updatetelnobyuid($this->user_id,$telnonew);
if($result_pass)
{
$this->user_model->SyncPhoneUserCenter($this->user_id, $telno, $telnonew);
//修改已经绑定的400号码
$this->load->model("esf_400_model");
$this->esf_400_model->update_telno($this->user_id , $telnonew ,$telno);
}
echo $result_pass ? 1 : 0;
if($result2[0]['id']>0 && $result2[0]['infofrom']==2)
{
//对原有账号进行失效操作
$this->user_model->updateuser($result2[0]['id'],array('is_use'=>0));
//对原有房源进行id修改
$this->house_model->updatehouseuid($result2[0]['id'],$this->user_id,'sell');
$this->house_model->updatehouseuid($result2[0]['id'],$this->user_id,'rent');
}
exit;
}
else
{
echo 2;
exit;
}
}
$this->load->view('edit_telno',$data);
}
/**
* 编辑头像文件
* @author cxf
*/
function edit_headfile()
{
if($this->input->post("action") == 'headfile')
{
$fileurl = common_file_upload("headfile", false, false, 340, 220);
if($fileurl)
{
echo "<script>window.parent.setHeadimgsrc('".$fileurl."');window.parent.document.getElementById('headpic').value='".$fileurl."';window.parent.jcSetImage();window.parent.changeShowPic('headShowPic');</script>";
}
else
{
echo "<script>window.parent.document.getElementById('jsUploadHeadPortrait').style.display = 'none';window.parent.document.getElementById('jsDialogE_msg').innerHTML='图片上传失败,请重试!';window.parent.openWin('jsDialogE');setTimeout(function(){window.parent.location.reload();},1000);</script>";
}
exit;
}
else if( $this->input->post("action") == 'savehead' )
{
$headpic = trim($this->input->post("headpic"));
$x = floatval($this->input->post("x"));
$y = floatval($this->input->post("y"));
$w = floatval($this->input->post("w"));
$h = floatval($this->input->post("h"));
$picfile = curl_get_contents($headpic);
if( $picfile )
{
$targ_w = $w;
$targ_h = $h;
$jpeg_quality = 100;
//FISHER 2013-6-22
//获取远程图片再裁剪处理,然后还要FTP上传到图片服务器,目前只能在本地创建临时文件,想不出其他办法了。
$filename = GB_CITY.'_'.md5($headpic).".jpg";
$cachefile = APPPATH."/cache/".$filename;
if($handle = fopen($cachefile, "wb") && $targ_w > 0 && $targ_h > 0)
{
$img_r = imagecreatefromstring($picfile);
$dst_r = ImageCreateTrueColor($targ_w, $targ_h);
imagecopyresampled($dst_r,$img_r,0,0,$x,$y,$targ_w,$targ_h,$w,$h);
imagejpeg($dst_r, $cachefile, $jpeg_quality);
@fclose($handle);
$_FILES['headfile']['nocheck'] = "house365";//uploadfile 类会检查这个文件是否是POST提交的文件,没办法啊绕过去。
$_FILES['headfile']['name'] = $filename;
$_FILES['headfile']['type'] = 'image/pjpeg';
$_FILES['headfile']['tmp_name'] = $cachefile;
$_FILES['headfile']['error'] = 0;
$_FILES['headfile']['size'] = @filesize($cachefile);
$this->load->library('uploadfile_class',array('filename'=>"headfile"));
$this->uploadfile_class->setFileType("jpg");
$this->uploadfile_class->setMaxSize(5120);
$this->uploadfile_class->setUploadType("ftp");
$this->uploadfile_class->setSaveDir("/".GB_CITY."house/");
$this->uploadfile_class->setWatermark(false);
$this->uploadfile_class->setImageCut(false);
if ($this->uploadfile_class->upload() == "success")
{
$headpicurl = $this->uploadfile_class->getSaveFileURL(); //图片地址
}
else
{
$headpicurl = "";
}
@unlink($cachefile);
if($headpicurl != "")
{
//更新用户头像
$id = $this->user_model->updateheadpic($this->user_id,$headpicurl);
if($id > 0)
{
echo "<script>window.parent.openWin('upfile-ok');</script>";
}
else
{
echo "<script>window.parent.openWin('warning');</script>";
}
}
else
{
echo "<script>window.parent.openWin('warning');</script>";
}
}
else
{
echo "<script>window.parent.openWin('warning');setTimeout(function(){window.parent.location.reload();},1000);</script>";
}
}
else
{
echo "<script>window.parent.openWin('warning');setTimeout(function(){window.parent.location.reload();},1000);</script>";
}
exit;
}
}
/**
* 我的问答
* @author cxf
*/
function myask()
{
$data['conf_where'] = 'ask';
$data['title'] = '我的问答';
//分页开始
$data['ask_num'] = $this->ask_model->getquelistnum($this->user_id);
$data['pagesize'] = 8;//设定每一页显示的记录数
$data['pages'] = $data['ask_num'] ? ceil($data['ask_num']/$data['pagesize']) : 0 ; //计算总页数
$data['page'] = $this->uri->segment(3) ? intval($this->uri->segment(3)) :1 ; // 获取当前页数
$data['page'] = ($data['page'] > $data['pages']) ? $data['pages'] : $data['page']; //判断跳转页数
$data['offset'] = $data['pagesize']*($data['page']-1); //计算记录偏移量
//获取问题列表
$data['asklist'] = $this->ask_model->getquelist($this->user_id,$data['offset'],$data['pagesize']);
$data['expertslist'] = $this->ask_model->getexperts();
//BI统计 ----- start----->
$data['isa_website'] = '2,19,99';
$data['isa_city'] = GB_CITY;
$data['isa_addones'] = '';
$data['isa_url'] = 'isa.house365.com/js/analyze.js?v=2.1';
//BI统计 ----- ent----->
//print_r($data);die;
$this->load->view('myask',$data);
}
/**
* 提问详情页跳转页
* @author cxf
*/
function qdetail($qid)
{
$arr=array('a_qid'=>$qid,'a_esta'=>1,'a_read'=>0);
$up= array('a_read'=>1);
$this->user_model->set_table('qa_answer');
$result = $this->user_model->save($arr,$up,'esfhouse');
//更新问答未读的cookie
$ask_num = $this->ask_model->getnewanswerbyuid($this->user_id);
setcoandsess('esfasknum',$ask_num);
echo '<script language="javascript">location= "'.get_questioninfo_url($qid).'";</script>';
}
/**
* 我的消息
* @author cxf
*/
function mymessage()
{
$data['conf_where'] = 'message';
$data['title'] = '我的消息';
//删除操作
if(isset($_POST['muldel']) && $_POST['muldel']=='del')
{
$result = $this->user_model->delmessage($_POST['actionid']);
echo $result;
exit;
}
//更新消息的点击状态
$this->user_model->updateannounceclick($this->user_id);
$data['num'] = $this->user_model->getmessagenumbyuid($this->user_id);
$data['pagesize'] = 8;//设定每一页显示的记录数
$data['pages'] = $data['num'] ? ceil($data['num']/$data['pagesize']) : 0 ; //计算总页数
$data['page'] = $this->uri->segment(3) ? intval($this->uri->segment(3)) :1 ; // 获取当前页数
$data['page'] = ($data['page']>$data['pages'] && $data['pages']!=0) ? $data['pages'] : $data['page']; //判断跳转页数
$data['offset'] = $data['pagesize']*($data['page']-1); //计算记录偏移量
$data['message'] = $this->user_model->getmessagebyuid($this->user_id,$data['offset'],$data['pagesize']);
//BI统计 ----- start----->
$data['isa_website'] = '2,19,82';
$data['isa_city'] = GB_CITY;
$data['isa_addones'] = '';
$data['isa_url'] = 'isa.house365.com/js/analyze.js?v=2.1';
//BI统计 ----- ent----->
$this->load->view('mymessage',$data);
}
function updateread()
{
$ids = $this->input->post("ids");
if(!empty($ids))
{
$id_arr = explode(',',$ids);
foreach($id_arr as $value)
{
$result = $this->user_model->updateannounce($value);
}
}else{
$result = $this->user_model->updateannounce($this->input->post("id"));
}
echo $result;
}
/**
* 实名认证弹窗
* @return array
*/
private function realNameData(){
$data = array();
$data['userInfo'] = $this->user_model->get_userdetail($this->user_id,array('truename','idno','auth_type','auth_open_id','passport_uid'));
// $data['imgUrl'] = 'http://mtt.house365.com/H5/pctoapp/index.php?city=nj&TFRouteType=1058&TFRouteParm=' .urlencode(urlencode('type=3&uuid='.$data['userInfo'][0]['passport_uid']));
// $data['imgUrl'] = 'http://newrent.house365.com/api/common/get-qr-code?size=144&margin=0&url='.urlencode($data['imgUrl']);
$data['imgUrl'] = '/images/downloadTFApp.png';
$data['imgUrlbg2'] = '/images/smbg2.png';
$data['imgUrlbg1'] = '/images/mybg.png';
if(GB_CITY == 'wh'){
$data['publishUrlSell'] = 'http://publish.wh.house365.com/?newWh=1&kind=1';
}else{
$data['publishUrlSell'] = "http://".GB_CITY.".publish.house365.com";
}
if(GB_CITY == 'nj'){
$data['publishUrlRent'] = "http://publish.house365.com/nj/publish";
}else if(GB_CITY == 'wh'){
$data['publishUrlRent'] = "http://publish.wh.house365.com/?newWh=1&kind=2";
}else{
$data['publishUrlRent'] = " http://".GB_CITY.".publish.house365.com/?kind=2";
}
return $data;
}
/**
* 我的房源二手房
* @author cxf
*/
function myhousesell()
{
header("Location:http://newrent.house365.com/user-center/sell-list");
die;
$data['conf_where'] = 'housesell';
$data['title'] = '我的房源';
$this->load->model('package_model');
$data['limitNumGtZero'] = $this->package_model->getLimitNumGtZero();
$data = array_merge($data,$this->realNameData());
if($_POST)
{
$id = $this->input->post('id');
$type = $this->input->post('type');
$code = $this->input->post('code');
$infotype = $this->input->post('infotype');
$payday = $this->input->post('payday');
$paytype = $this->input->post('paytype');
//推广处理
if($type =='tg'){
//更新房源状态,改为有意向
$result = $this->house_model->updatehouse($id,'sell',array('ischarge'=>'2'));
//记录客户意向
$result1 = $this->user_model->addusercharge($id, $paytype , $payday,$this->user_id );
if($result1>0)
{
//发送消息
$subject='您的房源推广申请已提交。';
$msg='您编号为"'.$id.'"的房源推广申请正在审核中,请耐心等待。';
$this->apply_class->send_systemmsg($this->user_id,$subject,$msg,1,GB_CITY);
//添加成功
echo '1';exit;
}else{
//添加失败
echo '3';exit;
}
}
//验证
if(md5($id.'house365')==$code)
{
if($type =='refresh')
{
//验证刷新可用次数
$num = $this->house_model->yzrefrshnum($this->user_id,$id,'sell');
//获取今日已刷新次数
$this->house_statistic_model->set_uid($this->user_id);
$this->house_statistic_model->set_city(GB_CITY);
$this->house_statistic_model->set_nocache(1);
$arr = $this->house_statistic_model->get_operate_list(2,$id,date("Y-m-d"));
//获得实际可刷新次数
$num = $num - count($arr);
if($num>0)
{
//更新房源刷新时间
$result = $this->house_model->updatehouse($id,'sell',array('updatetime'=>time()));
//记录刷新操作
$this->house_statistic_model->set_uid($this->user_id);
$this->house_statistic_model->set_city(GB_CITY);
$result = $this->house_statistic_model->sub_operate_log('sell' , $id , 2 );
if($result['is_ok'] == 1)
{
//发送消息
$subject='您的房源刷新成功';
$msg='您编号为"'.$id.'"房源刷新成功。如有疑问,请联系客服。';
$this->apply_class->send_systemmsg($this->user_id,$subject,$msg,1,GB_CITY);
//刷新成功
$arr1['msg'] = 1;
$arr1['num'] = $num-1;
print json_encode($arr1);exit;
}else{
//刷新失败
$arr1['msg'] = 4;
$arr1['num'] = $num;
print json_encode($arr1);exit;
}
}else{
//刷新次数不足
$arr1['msg'] = 3;
$arr1['num'] = $num;
print json_encode($arr1);exit;
}
}elseif($type =='del'){
//更新房源状态,相当于失效状态
$result = $this->house_model->updatehouse($id,'sell',array('esta'=>'2'));
//记录再发布操作
$this->house_statistic_model->set_uid($this->user_id);
$this->house_statistic_model->set_city(GB_CITY);
$result1 = $this->house_statistic_model->sub_operate_log('sell' , $id , 3 );
if($result>0)
{
//删除成功
echo '1';
exit;
}else{
//删除失败
echo '3';
exit;
}
}
elseif($type =='again_pub')
{
//更新房源状态
if(GB_CITY == 'nj')
{
if($infotype==1 or $infotype==2)
{
$expiretime = strtotime("+45 day");
}
else if($infotype==3 or $infotype==4 or $infotype==5 or $infotype==6)
{
$expiretime = strtotime("+60 day");
}
}
else
{
$expiretime = strtotime("+90 day");
}
$result = $this->house_model->republishhouse($id,'sell',array('esta'=>'1','creattime'=>time(),'updatetime'=>time(),'expiretime'=>$expiretime),GB_CITY);
//记录再发布操作
$this->house_statistic_model->set_uid($this->user_id);
$this->house_statistic_model->set_city(GB_CITY);
//$result1 = $this->house_statistic_model->sub_operate_log('sell' , $id , 5 ,1);
if($result>0)
{
$this->load->model('user_model');
//增加云信accid
$this->user_model->yunxin_accid($this->user_id);
//再发布成功
echo '1';exit;
}else{
//再发布失败
echo '3';exit;
}
}else{
//验证不通过,来源不正确
echo '2';exit;
}
}else{
//验证不通过,来源不正确
echo '2';exit;
}
}
$data['num'] = $this->house_model->gethousenumbyuid($this->user_id,'sell');
$data['pagesize'] = 8;//设定每一页显示的记录数
$data['pages'] = $data['num'] ? ceil($data['num']/$data['pagesize']) : 0 ; //计算总页数
$data['page'] = $this->uri->segment(3) ? intval($this->uri->segment(3)) :1 ; // 获取当前页数
$data['page'] = ($data['page']>$data['pages'] && $data['pages']!=0) ? $data['pages'] : $data['page']; //判断跳转页数
$data['offset'] = $data['pagesize']*($data['page']-1); //计算记录偏移量
if(GB_CITY=='nj' || GB_CITY=='wh')
{
$data['house_array'] = $this->house_model->gethousebyuid($this->user_id,'sell',array('id','address','buildarea','price','updatetime','creattime','esta','ischarge','pic1','district','streetid','blockshowname','infotype','room','hall','fitment','buildarea','ischarge','telno','floor ','subfloor','totalfloor','survey'),$data['offset'],$data['pagesize']);
}
else
{
$data['house_array'] = $this->house_model->gethousebyuid($this->user_id,'sell',array('id','address','buildarea','price','updatetime','creattime','esta','ischarge','pic1','district','streetid','blockshowname','infotype','room','hall','fitment','buildarea','ischarge','telno','floor ','subfloor','totalfloor'),$data['offset'],$data['pagesize']);
}
if (is_array($data['house_array'])) {
if(GB_CITY=='nj'){
$this->load->model('survey_model');
$modelSurvey = new Survey_model();
}elseif(GB_CITY == 'wh'){
$this->load->model('vr_model');
$modelSurvey = new Vr_model();
}
foreach($data['house_array'] as &$value) {
$value['survey_status'] = '';
$value['can_survey'] = false;
$value['show_survey_icon'] = false;
if(intval($value['esta']) != 1){
$value['survey'] = 0;
}
if ($data['limitNumGtZero'][5]['sell'] && intval($value['survey']) != 1 && intval($value['esta']) == 1 && in_array(GB_CITY, array_keys($this->surveyConfig)) && in_array(intval($value['infotype']), $this->surveyConfig[GB_CITY]['surveyInfotype']) && in_array($value['district'], $this->surveyConfig[GB_CITY]['surveyDistrict'])) {
$value['can_survey'] = true;
}
if(intval($value['survey']) == 1) {
if(GB_CITY=='nj'){
$surveyInformation = $modelSurvey->getInformation('sell', $value['id']);
$status = isset($surveyInformation[0]['status']) ? intval($surveyInformation[0]['status']) : 0;
if ($status == 3 && !empty($surveyInformation[0]['time_order']) && time() > intval($surveyInformation[0]['time_order'])) {
$status = 4;
}
if($status != 2){
$value['show_survey_icon'] = true;
}
$value['survey_status'] = isset($this->surveyStatus[$status]) ? $this->surveyStatus[$status] : '实勘未知状态';
}elseif(GB_CITY=='wh'){
$surveyInformation = $modelSurvey->getVrInfoByHouseId('sell', $value['id']);
if($surveyInformation){
$value['show_survey_icon'] = $surveyInformation['show_icon'];
$value['survey_status'] = $surveyInformation['vr_status_word'];
}
}
}
//获取房源已有套餐
if(in_array(GB_CITY,$this->openPayCitys)){
$packageData = $this->package_model->getHousePackageNew($value['id'],'sell');
if($packageData){
if(isset($packageData['leftTime'])) $value['leftTime'] = $packageData['leftTime'];
if(in_array(1,$packageData['package_types']) || in_array(2,$packageData['package_types']) || in_array(3,$packageData['package_types'])){
$value['promoting'] = 1;
}else{
$value['promoting'] = 0;
}
}
}
}
}
//中奖通知 5.25-8.31
$data['is_win'] = $this->_get_is_win();
//BI统计 ----- start----->
$data['isa_website'] = '2,19,72';
$data['isa_city'] = GB_CITY;
$data['isa_addones'] = '';
$data['isa_url'] = 'isa.house365.com/js/analyze.js?v=2.1';
//BI统计 ----- ent----->
$data['userInfo'] = $this->user_model->get_userdetail($this->user_id,array('truename','idno','auth_type','auth_open_id','passport_uid','bank_type'));
$this->load->view('myhousesell',$data);
}
/**
* 我的房源二手房
* @author cxf
*/
function myhouserent()
{
header("Location:http://newrent.house365.com/user-center/rent-list");
die;
global $house;
$data['conf_where'] = 'houserent';
$data['title'] = '我的房源';
$data = array_merge($data,$this->realNameData());
$this->load->model('package_model');
$data['limitNumGtZero'] = $this->package_model->getLimitNumGtZero();
if($_POST)
{
$id = $this->input->post('id');
$type = $this->input->post('type');
$code = $this->input->post('code');
$infotype = $this->input->post('infotype');
$payday = $this->input->post('payday');
$paytype = $this->input->post('paytype');
//推广处理
if($type =='tg'){
//更新房源状态,改为有意向
$result = $this->house_model->updatehouse($id,'rent',array('ischarge'=>'2'));
//记录客户意向
$result1 = $this->user_model->addusercharge($id, $paytype , $payday,$this->user_id,'rent' );
if($result1>0)
{
//发送消息
$subject='您的房源推广申请已提交。';
$msg='您编号为"'.$id.'"的房源推广申请正在审核中,请耐心等待。';
$this->apply_class->send_systemmsg($this->user_id,$subject,$msg,1,GB_CITY);
//添加成功
echo '1';exit;
}else{
//添加失败
echo '3';exit;
}
}
//验证
if(md5($id.'house365')==$code)
{
if($type =='refresh')
{
//验证刷新可用次数
$num = $this->house_model->yzrefrshnum($this->user_id,$id,'rent');
//获取今日已刷新次数
$this->house_statistic_model->set_uid($this->user_id);
$this->house_statistic_model->set_city(GB_CITY);
$this->house_statistic_model->set_nocache(1);
$arr = $this->house_statistic_model->get_operate_list(2,$id,date("Y-m-d"));
//获得实际可刷新次数
$num = $num - count($arr);
if($num>0)
{
//更新房源刷新时间
$result = $this->house_model->updatehouse($id,'rent',array('updatetime'=>time()));
if(empty($result))
{
$arr1['msg'] = 4;
$arr1['num'] = $num;
print json_encode($arr1);exit;
}
//记录刷新操作
$this->house_statistic_model->set_uid($this->user_id);
$this->house_statistic_model->set_city(GB_CITY);
$result = $this->house_statistic_model->sub_operate_log('rent' , $id , 2,1);
if($result['is_ok'] == 1)
{
//发送消息
$subject='您的房源刷新成功';
$msg='您编号为"'.$id.'"房源刷新成功。如有疑问,请联系客服。';
$this->apply_class->send_systemmsg($this->user_id,$subject,$msg,1,GB_CITY);
//刷新成功
$arr1['msg'] = 1;
$arr1['num'] = $num-1;
print json_encode($arr1);exit;
}else{
//刷新失败
$arr1['msg'] = 4;
$arr1['num'] = $num;
print json_encode($arr1);exit;
}
}else{
//刷新次数不足
$arr1['msg'] = 3;
$arr1['num'] = $num;
print json_encode($arr1);exit;
}
}elseif($type =='del'){
//更新房源状态
$result = $this->house_model->updatehouse($id,'rent',array('esta'=>2));
//记录再发布操作
$this->house_statistic_model->set_uid($this->user_id);
$this->house_statistic_model->set_city(GB_CITY);
$result1 = $this->house_statistic_model->sub_operate_log('rent' , $id , 3 );
if($result>0)
{
//通知爱租哪
if(GB_CITY == 'nj' || GB_CITY == 'hf')
{
$houseData = $this->house_model->gethousebywhere(array('id' => $id),'rent',array('iszhizu'),1);
if(!empty($houseData) && $houseData[0]['iszhizu'] == '1')
{
$url = 'http://mtapi.house365.com/?method=zhizu.ApiRent_syncEsf2AznStatus&city='.GB_CITY.'&id='.$id.'&esta=2&uid='.$this->user_id;
curl_get_contents($url);
}
}
//删除成功
echo '1';exit;
}
else
{
//删除失败
echo '3';exit;
}
}
elseif($type =='again_pub')
{
//更新房源状态
if(GB_CITY == 'nj')
{
if($infotype == 1 or $infotype == 2)
{
$expiretime = strtotime("+35 day");
}
else if($infotype==3 or $infotype==4 or $infotype==5 or $infotype==6)
{
$expiretime = strtotime("+60 day");
}
}
else
{
$expiretime = strtotime("+90 day");
}
$result = $this->house_model->republishhouse($id,'rent',array('esta'=>1,'creattime'=>time(),'updatetime'=>time(),'expiretime'=>$expiretime),GB_CITY);
//记录再发布操作
$this->house_statistic_model->set_uid($this->user_id);
$this->house_statistic_model->set_city(GB_CITY);
$result1 = $this->house_statistic_model->sub_operate_log('rent' , $id , 5 );
if($result>0)
{
//通知爱租哪
if(GB_CITY == 'nj' || GB_CITY == 'hf')
{
$houseData = $this->house_model->gethousebywhere(array('id' => $id),'rent',array('iszhizu'),1);
if(!empty($houseData) && $houseData[0]['iszhizu'] == '1')
{
$url = 'http://mtapi.house365.com/?method=zhizu.ApiRent_syncEsf2AznStatus&city='.GB_CITY.'&id='.$id.'&esta=1&uid='.$this->user_id;
curl_get_contents($url);
}
}
$this->load->model('user_model');
//增加云信accid
$this->user_model->yunxin_accid($this->user_id);
//再发布成功
echo '1';exit;
}else{
//再发布失败
echo '3';exit;
}
}else{
//验证不通过,来源不正确
echo '2';exit;
}
}else{
//验证不通过,来源不正确
echo '2';exit;
}
}
$data['num'] = $this->house_model->gethousenumbyuid($this->user_id,'rent');
$data['pagesize'] = 8;//设定每一页显示的记录数
$data['pages'] = $data['num'] ? ceil($data['num']/$data['pagesize']) : 0 ; //计算总页数
$data['page'] = $this->uri->segment(3) ? intval($this->uri->segment(3)) :1 ; // 获取当前页数
$data['page'] = ($data['page']>$data['pages'] && $data['pages']!=0) ? $data['pages'] : $data['page']; //判断跳转页数
$data['offset'] = $data['pagesize']*($data['page']-1); //计算记录偏移量
//获取房源
$data['house_array'] = $this->house_model->gethousebyuid($this->user_id,'rent',array('id','address','buildarea','price','updatetime','creattime','esta','ischarge','pic1','district','streetid','blockshowname','infotype','room','hall','fitment','buildarea','priceunit','ischarge','telno','floor ','subfloor','totalfloor'),$data['offset'],$data['pagesize']);
//获取房源已有套餐
if(in_array(GB_CITY,$this->openPayCitys)){
foreach($data['house_array'] as &$value) {
$packageData = $this->package_model->getHousePackageNew($value['id'],'rent');
if($packageData){
if(isset($packageData['leftTime'])) $value['leftTime'] = $packageData['leftTime'];
if(in_array(1,$packageData['package_types']) || in_array(2,$packageData['package_types']) || in_array(3,$packageData['package_types'])){
$value['promoting'] = 1;
}else{
$value['promoting'] = 0;
}
}
}
}
$data['priceunit'] = $house['priceunit'];
//中奖通知 5.25-8.31
$data['is_win'] = $this->_get_is_win();
//BI统计 ----- start----->
$data['isa_website'] = '2,19,73';
$data['isa_city'] = GB_CITY;
$data['isa_addones'] = '';
$data['isa_url'] = 'isa.house365.com/js/analyze.js?v=2.1';
//BI统计 ----- ent----->
$data['userInfo'] = $this->user_model->get_userdetail($this->user_id,array('truename','idno','auth_type','auth_open_id','passport_uid','bank_type'));
$this->load->view('myhouserent',$data);
}
/**
* 获取当前会员是否获取奖品
*
*/
private function _get_is_win()
{
$result = array();
if(GB_CITY == 'nj' && false)
{
$time = time();
$start_date = mktime(0,0,0,5,25,date('Y'));
$end_date = mktime(23,59,59,12,23,date('Y'));
if($start_date <= $time && $time <= $end_date)
{
$user_data = $this->user_model->get_user_data($this->user_id);
if(!empty($user_data) && !empty($user_data['telno']))
{
$result = $this->user_model->check_is_win($this->user_id,$user_data['telno'],$start_date,$end_date);
}
}
}
return $result;
}
//价格提醒处理ajax
function price_remind_ajax(){
// error_reporting(7);
// ini_set("display_errors",true);
$this->load->model("user_model");
$houseid = $this->input->post('houseid');
$type = $this->input->post('type');
$flag = $this->input->post('flag');
$priceRemindNum = $this->user_model->getPriceRemindNum($this->user_id);
if($priceRemindNum>=5&&$flag==1){//满4条提示
$result = 3;
}else{
$isChoice = $this->user_model->isCheckPriceRemind($this->user_id,$houseid);
//var_dump($isChoice);exit();
if(is_array($isChoice)){
if(empty($isChoice)&&$flag==1){
$result = $this->user_model->addPriceRemind($houseid,$this->user_id);
//echo "444";
}elseif($isChoice[0]['status']==1&&$flag==0){
$result = $this->user_model->updatePrcieRemind($houseid,$this->user_id,0);
}elseif($isChoice[0]['status']==0&&$flag==1){
$result = $this->user_model->updatePrcieRemind($houseid,$this->user_id,1);
}
}
}
echo $result = $result ? $result :0;
}
public function pay(){
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept');
if(GB_CITY != 'nj' && GB_CITY != 'wh'){
return $this->jump(USER_CENTER,'该城市暂未开通此功能!',3000,'warning');
}
//定义支持的支付类型
$payTypeArr = array('wxpay');
//获取房源属性
$packageId = intval($this->input->post('package_id',true));
$houseId = intval($this->input->post('house_id',true));
$tbl = addslashes($this->input->post('tbl',true));
$packageType = intval($this->input->post('package_type',true));
$packageKeyword = intval($this->input->post('package_keyword',true));
$day = intval($this->input->post('day_'.$packageType,true));
$payType = addslashes($this->input->post('pay_type',true));
// 租房8折优惠券 20200507添加
$use_coupon = intval($this->input->post('use_coupon',true));
if(empty($packageId) || empty($houseId) || empty($tbl) || empty($packageType) || (!in_array($packageType,array(4,5)) && empty($day)) || empty($payType) || !in_array($payType,$payTypeArr)){
return $this->jump(USER_CENTER,'参数缺失',3000,'warning');
}
$searchArr['id'] = $houseId;
$searchArr['uid'] = $this->user_id;
$searchArr['infofrom'] = 1;
$searchArr['esta'] = 1;
//获取房源信息
$houseData = $this->house_model->gethousebywhere($searchArr,$tbl,array('id,infotype,district,telno'),1);
if(empty($houseData)){
return $this->jump(USER_CENTER,'房源状态异常',3000,'warning');
}
$infoType = $houseData[0]['infotype'] == 1 ? 1 : 2;
//加载套餐model类
$this->load->model("package_model");
$packageData = $this->package_model->getDetailById($packageId);
if(empty($packageData)){
return $this->jump(USER_CENTER,'套餐状态异常',3000,'warning');
}
//价格数据
$packageData['package_desc'] = unserialize($packageData['package_desc']);
foreach($packageData['package_desc'] as $item){
if($packageType == 4){
$price = floatval($item['price']);
}else if($packageType == 5){
if($item['property_type'] == $infoType){
$price = floatval($item['price']);
//处理折扣
if(isset($item['discount']) && $item['discount'] >0){
$price = $this->pirceDiscount($price,$item['discount']);
}
}
}else{
if($item['property_type'] == $infoType && $item['day'] == $day){
$price = floatval($item['price']);
if(GB_CITY == 'wh' && $packageType == 2){
//处理折扣
if(isset($item['discount']) && $item['discount'] >0){
$price = $this->pirceDiscount($price,$item['discount']);
}
}
// 列表套餐8折券使用 20200507
if( GB_CITY == 'nj' && $packageType == 2 && $tbl == 'rent'){
//
$checkbox_status = 0;
// 检查是否有可用的优惠券,如果有则使用,如果无,则跳转提示
$userInfoData = $this->user_model->getuserdetail($this->user_id);
$passport_uid = $userInfoData ? $userInfoData['passport_uid'] : 0;
// 测试数据
if( $this->user_id == '1785149' || $this->user_id == '3367096'){
$price = 0.04;
}
if( isset($use_coupon) && $use_coupon == 1){
$check_coupon = $this->rent_coupon_model->checkCoupon($passport_uid);
if( !$check_coupon ){
return $this->jump(USER_CENTER,'租房优惠券状态异常',3000,'warning');
}
$checkbox_status = 1;
// 列表优先套餐8折
$price = sprintf("%.2f",$price * 0.8);
// 锁定半小时
$this->rent_coupon_model->lockCoupon($passport_uid);
}
// 设置8折优惠券的选中状态
$this->rent_coupon_model->setCheckbox($passport_uid,$checkbox_status);
}
}
}
}
if($this->user_id == 2909549 || $this->user_id == 3137198){
$price = 0.01;
}
//校验参数正确性
if($packageType != $packageData['package_type'] || empty($price) || $price <= 0){
return $this->jump(USER_CENTER,'套餐价格数据异常',3000,'warning');
}
if($packageType == 1 && ( $packageKeyword != $packageData['package_keyword'] || $packageKeyword <= 0 ) ){
return $this->jump(USER_CENTER,'套餐关键词异常',3000,'warning');
}
//首页推荐需要限制数量
if($packageType == 1){
//已售出和已锁定的套餐数量
$count = $this->package_model->getPackageNum($packageKeyword,$tbl);
if($count >= $packageData['package_num']){
return $this->jump(USER_CENTER,'套餐已售完',3000,'warning');
}
}
//wh实勘限制购买数量
if($packageType == 5){
//城市限制
if (!in_array($houseData[0]['district'], $this->surveyConfig[GB_CITY]['surveyDistrict'])) {
return $this->jump(USER_CENTER,'所在区域实勘服务暂未开通',3000,'warning');
}
$this->load->model('vr_model');
$countVr = $this->vr_model->getVrApplyNowNum(1,3); //sell 个人房源
$countOrder = $this->package_model->getPackageOrderNumByType($packageType,$tbl); //未支付有效订单
if( $countVr+$countOrder >= $packageData['package_num']){
return $this->jump(USER_CENTER,'套餐已售完',3000,'warning');
}
}
//首页推荐和列表排序在有效期内不能同时购买(南京租房除外 修改日期2020/3/4)
//获取该房源的套餐状态
$housePackage = $this->package_model->getHousePackage($houseId,$tbl);
//获取禁止的套餐数组
$banHousePackage = array();
if(!empty($housePackage)){
foreach($housePackage as $k =>$v){
if($v == 1 || $v == 2){
if(GB_CITY == 'nj' && $tbl == 'rent'){
$banHousePackage[] = $v;
}else{
$banHousePackage[] = 1;
$banHousePackage[] = 2;
}
}
if($v == 3){
$banHousePackage[] = 3;
}
}
}
if(in_array($packageData['package_type'],$banHousePackage)){
return $this->jump(USER_CENTER,'请勿重复购买套餐',3000,'warning');
}
//创建订单
$tblArr = array('sell' => 1 ,'rent' => 2);
$tableId = $tblArr[$tbl];
$orderData = array();
$orderData['transaction_id'] = $this->package_model->getTransactionId($packageType);
$orderData['user_id'] = $this->user_id;
$orderData['house_type'] = $tableId;
$orderData['house_id'] = $houseId;
$orderData['house_tel'] = $houseData[0]['telno'];
$orderData['package_id'] = $packageId;
$orderData['package_type'] = $packageType;
if($packageType == 1){
$orderData['package_keyword'] = $packageKeyword;
}
$orderData['package_days'] = $day;
$orderData['price'] = $price;
$orderData['create_time'] = time();
$orderData['pay_type'] = $payType;
$orderData['source'] = 1;
$orderData['ip'] = get_ip();
$orderId = $this->package_model->createOrder($orderData);
$orderData['id'] = $orderId;
//极小概率出现的订单号重复处理
if($orderId <= 0){
return $this->jump(USER_CENTER ,'订单创建失败',3000,'warning');
}
$data = $this->getWxPayCodeByHouse365($orderId);
if($data['status'] != 1){
return $this->jump(USER_CENTER , $data['msg'],3000,'warning');
}
$data['orderData'] = $orderData;
$data['title'] = '微信支付';
$this->load->view('wxpay',$data);
}
/**
* 折扣
* @param $price
* @param $discount
*/
private function pirceDiscount($price,$discount){
return $price*$discount/10;
}
/**
* 向house365支付中台查询订单状态
* @param $transactionId
* @return string
*/
public function queryOrder($transactionId){
$data = array('status' => 0);
if(!in_array(GB_CITY,$this->openPayCitys)){
echo json_encode($data);exit;
}
$this->load->model("package_model");
$curlData = array();
$curlData['serviceCode'] = 'pay';
$curlData['serviceName'] = 'queryOrder';
$curlData['actId'] = $this->openPayCitysActId[GB_CITY];
$curlData['tradeNo'] = $transactionId;
$curlData['sign'] = $this->package_model->makeSign($curlData);
$url = 'https://pay.house365.com/house365-pay-web/rest/interface';
$result = SendDataByCurl($url,$curlData);
$result = json_decode($result,true);
if(!empty($result['status'])){
$result['status'] = iconv('utf-8','gbk',$result['status']);
}
if(!empty($result) && $result['result'] == 'SUCCESS' && $result['status'] == '支付成功'){
$data['status'] = 1;
//测试环境无法回调的处理
//$orderInfo = $this->package_model->getOrderInfoByTransactionId($transactionId);
//$this->package_model->payFinish($orderInfo);
}
echo json_encode($data);exit;
}
/**
* 根据订单ID生成微信支付二维码
* @param $orderId 订单ID
* @return array
*/
private function getWxPayCodeByHouse365($orderId){
//加载套餐model类
$data['status'] = 0;
$this->load->model("package_model");
$packageData = $this->package_model->getOrderInfoById($orderId);
if(empty($packageData) || $packageData['order_status'] == 0 || $packageData['pay_status'] == 1){
$msg = '订单信息异常';
$data['msg'] = $msg;
return $data;
}
$transaction_id = $packageData['transaction_id'];
$price = $packageData['price'];
$notifyUrl = 'http://user.house365.com/esf_center_api/notify?city='.GB_CITY;
//$price = 0.01;
//$notifyUrl = 'http://esfadmin.house365.com/test.php';
$packageTypeName = $this->package_model->getPackageTypeName($packageData['package_type']);
$subject = '个人房源增值服务-'.$packageTypeName;
//拼接数组
$curlData = array();
$curlData['serviceCode'] = 'pay';
$curlData['serviceName'] = 'createAPPReceiptOrder';
//活动标识
switch (GB_CITY){
case 'nj' :
$curlData['actId'] = '57';
break;
case 'wh' :
$curlData['actId'] = '82';
break;
}
$curlData['tradeNo'] = $transaction_id;
$curlData['version'] = '1.0';
$curlData['notifyUrl'] = $notifyUrl;
$curlData['amount'] = $price * 100;
$curlData['city'] = GB_CITY;
$curlData['wechatTradeType'] = 1;
$curlData['subject'] = iconv('gbk','utf-8',$subject);
//订单过期时间为30分钟,考虑到网络延迟加上10S
$curlData['timeExpire'] = date("YmdHis", time() + 30 * 60 + 10);
$IpHostAllow =explode('.',get_ip());
if($IpHostAllow[0] == '192' && ($_COOKIE['is_test_wh'] == 'test' || (isset($_COOKIE['esfuserid']) && $_COOKIE['esfuserid'] == 2640088))){
$orderInfo = $this->package_model->getOrderInfoByTransactionId($transaction_id);
$this->package_model->payFinish($orderInfo);
$data['status'] = 1;
$data['msg'] = "支付完成!";
$data['is_test'] = 1;
return $data;
}
$curlData['sign'] = $this->package_model->makeSign($curlData);
$url = 'https://pay.house365.com/house365-pay-web/rest/interface';
$result = SendDataByCurl($url,$curlData);
$result = json_decode($result,true);
if(!empty($result['payParams']) && !is_array($result['payParams'])){
$result['payParams'] = json_decode($result['payParams'],true);
}
if( empty($result) || $result['result'] != 'SUCCESS' || empty($result['payParams']['code_url']) ){
$msg = !empty($result['payParams']['msg']) ? $result['payParams']['msg'] : $result['msg'];
//若未返回错误信息则返回默认错误信息
$msg = !empty($msg) ? iconv('utf-8','gbk',$msg): '支付参数有误';
$data['msg'] = $msg;
return $data;
}
$data['status'] = 1;
//此处调用微信支付的生成二维码接口,后期如果微信接口不能访问请自行用qrcode生成二维码
// $data['url'] = 'http://paysdk.weixin.qq.com/example/qrcode.php?data='.urlencode($result['payParams']['code_url']);
// $data['url'] = 'http://qr.liantu.com/api.php?text='.urlencode($result['payParams']['code_url']);
$data['url'] = 'http://newrent.house365.com/api/common/get-qr-code?size=298&margin=0&url='.urlencode($result['payParams']['code_url']);
return $data;
}
/**
* 根据房源获取该房源可以购买的套餐
* @param int $houseId 房源ID
* @param string $tbl sell/rent
* @param string $type promote:房源推广 refresh:房源刷新
*/
public function getPersonalHousePackage($houseId , $tbl = 'sell' , $type = 'promote')
{
if(GB_CITY != 'nj' && GB_CITY != 'wh'){
return;
}
$this->load->model('package_model');
$packageData = $this->package_model->getPackageByHouseId($houseId,$tbl);
$promoteData = array();
$refreshData = array();
$surveyData = array();
foreach($packageData as $key => $value){
if($value['package_type'] == 1 && GB_CITY == 'nj'){
$promoteData[] = $value;
}
if($value['package_type'] == 2 ){
$promoteData[] = $value;
}
if($value['package_type'] == 3 || $value['package_type'] == 4){
$refreshData[] = $value;
}
if($value['package_type'] == 5 && GB_CITY == 'wh'){
$surveyData[] = $value;
}
}
if($type == 'promote'){
echo json_encode($promoteData);
}
if($type == 'refresh'){
echo json_encode($refreshData);
}
if($type == 'survey'){
echo json_encode($surveyData);
}
}
public function orderInvoice($orderId = '0'){
if(GB_CITY != 'nj' && GB_CITY != 'wh'){
return $this->jump(USER_CENTER ,'当前城市暂未开通此功能',3000,'warning');
}
//获取订单状态
$this->load->model("package_model");
$orderData = $this->package_model->getOrderInfoById($orderId);
//校验订单状态
if($orderData['user_id'] != $this->user_id || $orderData['order_status'] != 1 ){
return $this->jump(USER_CENTER ,'订单数据异常',3000,'warning');
}
//获取发票是否创建
$invoiceData = $this->package_model->getOrderInvoice($orderId);
if(!empty($invoiceData)){
return $this->jump(USER_CENTER ,'发票已经创建',3000,'warning');
}
//获取用户最新的发票信息
$oldInvoice = $this->package_model->getOrderInvoiceByUserId($this->user_id);
$oldInvoice['pic'] = !empty($oldInvoice['pic']) ? explode(',', $oldInvoice['pic']) : array();
$data['oldInvoice'] = $oldInvoice;
$data['orderData'] = $orderData;
$data['title'] = '发票在线填写';
$this->load->model("tel_model");
$data['telno_config'] = $this->tel_model->getTelInfoByType(tel_model::TYPE3);
$data['address_config'] = isset($this->address[GB_CITY]) ? $this->address[GB_CITY] : '';
$this->load->view('order_invoice',$data);
}
public function createOrderInvoice(){
if(GB_CITY != 'nj' && GB_CITY != 'wh'){
return;
}
$orderId = intval($this->input->post('order_id',true));
$userType = intval($this->input->post('user_type',true));
$type = intval($this->input->post('type',true));
$username = addslashes($this->input->post('username',true));
$identityCard = addslashes($this->input->post('identity_card',true));
$invoiceTitle = addslashes($this->input->post('invoice_title',true));
$invoiceNumber = addslashes($this->input->post('invoice_number',true));
$bank = addslashes($this->input->post('bank',true));
$phone = addslashes($this->input->post('phone',true));
$address = addslashes($this->input->post('address',true));
$sendType = addslashes($this->input->post('send_type',true));
$bankAccount = addslashes($this->input->post('bank_account',true));
$mailingUsername = addslashes($this->input->post('mailing_username',true));
$mailingAddress = addslashes($this->input->post('mailing_address',true));
$mailingPhone = addslashes($this->input->post('mailing_phone',true));
$picArr = $this->input->post('p_filename',true);
//参数判断
if(empty($orderId) || empty($type) || empty($userType) || empty($sendType)){
return $this->jump(USER_CENTER ,'参数缺失',3000,'warning');
}
if($userType == 1 && $type == 2){
return $this->jump(USER_CENTER ,'参数错误',3000,'warning');
}
if($userType == 1 && ( empty($username) || empty($identityCard))){
return $this->jump(USER_CENTER ,'参数缺失',3000,'warning');
}
if($userType == 2 && ( empty($invoiceTitle) || empty($invoiceNumber) ) ){
return $this->jump(USER_CENTER ,'参数缺失',3000,'warning');
}
if($type == 2 && ( empty($bank) || empty($phone) || empty($address) || empty($bankAccount) || empty($picArr)) ){
return $this->jump(USER_CENTER ,'参数缺失',3000,'warning');
}
if($sendType == 1 && ( empty($mailingUsername) || empty($mailingAddress) || empty($mailingPhone) ) ){
return $this->jump(USER_CENTER ,'参数缺失',3000,'warning');
}
//获取订单状态
$this->load->model("package_model");
$orderData = $this->package_model->getOrderInfoById($orderId);
//校验订单状态
if($orderData['user_id'] != $this->user_id || $orderData['pay_status'] != 1 || $orderData['order_status'] != 1 ){
return $this->jump(USER_CENTER ,'订单数据异常',3000,'warning');
}
//获取发票是否创建
$invoiceData = $this->package_model->getOrderInvoice($orderId);
if(!empty($invoiceData)){
return $this->jump(USER_CENTER ,'发票已经创建',3000,'warning');
}
$data = array();
$data['order_id'] = $orderId;
$data['type'] = $type;
$data['price'] = $orderData['price'];
$data['send_type'] = $sendType;
$data['user_type'] = $userType;
if($userType == 1){
$data['username'] = $username;
$data['identity_card'] = $identityCard;
}
if($userType == 2){
$data['invoice_title'] = $invoiceTitle;
$data['invoice_number'] = $invoiceNumber;
$pic = addslashes( implode(',',$picArr) );
$data['pic'] = $pic;
}
if($type == 2){
$data['bank'] = $bank;
$data['bank_account'] = $bankAccount;
$data['phone'] = $phone;
$data['address'] = $address;
}
if($sendType == 1){
$data['mailing_username'] = $mailingUsername;
$data['mailing_address'] = $mailingAddress;
$data['mailing_phone'] = $mailingPhone;
}
$invoiceId = $this->package_model->createOrderInvoice($data);
if($invoiceId <= 0){
return $this->jump(USER_CENTER ,'发票生成失败',3000,'warning');
}
//获取推广信息
$promoteData = $this->package_model->getPromoteByOrderId($orderId);
$promoteId = $promoteData['id'];
$updateData = array();
$updateData['invoice_id'] = $invoiceId;
$updateData['invoice_status'] = 0;
$where = array();
$where['id'] = $promoteId;
$this->package_model->updatePromote($updateData, $where);
return $this->jump(USER_CENTER);
}
/**
* form表单提示信息 2017-12-18
* @param string $url
* @param string $msg
* @param string $time
* @param string $type
*/
private function jump( $url = 'user.house365.com' , $msg = '提交成功', $time ='3000', $type = 'success'){
$data['msg'] = $msg;
$data['url'] = $url;
$data['time'] = $time;
$data['type'] = $type;
$this->load->view('form_alert',$data);
}
//我的订单
public function myorder(){
$data['conf_where'] = 'myorder';
$data['title'] = '我的订单';
$data['pagesize'] = 10;//记录每页的条数
$data['page'] = $this->uri->segment(3) ? intval($this->uri->segment(3)) :1 ; // 获取当前页数
$data['totalsize'] = $this->user_model->myorder_count($this->user_id);//记录总数
$data['totalpage'] = ceil($data['totalsize']/$data['pagesize']);
$orderdata = $this->user_model->myorder_list($this->user_id,$data['page'],$data['pagesize']);
$data['orders'] = $orderdata;
$this->load->view('myorder',$data);
}
//图形验证码
public function imageCode(){
$this->user_model->imageCode();
}
//图形验证码验证
public function imageCodeVerify(){
$re = $this->user_model->imageCodeVerify();
$re['msg'] = iconv('gbk','utf-8',$re['msg']);
echo json_encode($re);die;
}
//银行卡实名认证
public function bankCertify(){
$re = $this->user_model->bankCertify();
$re['msg'] = iconv('gbk','utf-8',$re['msg']);
if(!empty($re['data']['truename'])){
$re['data']['truename'] = iconv('gbk','utf-8',$re['data']['truename']);
}
echo json_encode($re);die;
}
}
\ No newline at end of file
...@@ -123,6 +123,23 @@ $db['dsn_esfbak']['swap_pre'] = ''; ...@@ -123,6 +123,23 @@ $db['dsn_esfbak']['swap_pre'] = '';
$db['dsn_esfbak']['autoinit'] = FALSE; $db['dsn_esfbak']['autoinit'] = FALSE;
$db['dsn_esfbak']['stricton'] = FALSE; $db['dsn_esfbak']['stricton'] = FALSE;
$db['dsn_esfuser_dev']['hostname'] = '192.168.105.107';
$db['dsn_esfuser_dev']['username'] = 'root';
$db['dsn_esfuser_dev']['password'] = 'd53b21ffb24d9c34';
$db['dsn_esfuser_dev']['database'] = 'user';
$db['dsn_esfuser_dev']['dbdriver'] = 'mysql';
$db['dsn_esfuser_dev']['dbprefix'] = '';
$db['dsn_esfuser_dev']['pconnect'] = FALSE;
$db['dsn_esfuser_dev']['db_debug'] = FALSE;
$db['dsn_esfuser_dev']['cache_on'] = FALSE;
$db['dsn_esfuser_dev']['cachedir'] = '';
$db['dsn_esfuser_dev']['char_set'] = 'gbk';
$db['dsn_esfuser_dev']['dbcollat'] = 'gbk';
$db['dsn_esfuser_dev']['swap_pre'] = '';
$db['dsn_esfuser_dev']['autoinit'] = FALSE;
$db['dsn_esfuser_dev']['stricton'] = FALSE;
if(GB_CITY=='nj') if(GB_CITY=='nj')
{ {
$db['dsn_esfhouse']['hostname'] = $conf_db_host; $db['dsn_esfhouse']['hostname'] = $conf_db_host;
...@@ -156,6 +173,23 @@ if(GB_CITY=='nj') ...@@ -156,6 +173,23 @@ if(GB_CITY=='nj')
$db['dsn_esfhousebak']['swap_pre'] = ''; $db['dsn_esfhousebak']['swap_pre'] = '';
$db['dsn_esfhousebak']['autoinit'] = FALSE; $db['dsn_esfhousebak']['autoinit'] = FALSE;
$db['dsn_esfhousebak']['stricton'] = FALSE; $db['dsn_esfhousebak']['stricton'] = FALSE;
$db['dsn_esfhouse_dev']['hostname'] = '192.168.105.107';
$db['dsn_esfhouse_dev']['username'] = 'root';
$db['dsn_esfhouse_dev']['password'] = 'd53b21ffb24d9c34';
$db['dsn_esfhouse_dev']['database'] = 'house';
$db['dsn_esfhouse_dev']['dbdriver'] = 'mysql';
$db['dsn_esfhouse_dev']['dbprefix'] = '';
$db['dsn_esfhouse_dev']['pconnect'] = FALSE;
$db['dsn_esfhouse_dev']['db_debug'] = FALSE;
$db['dsn_esfhouse_dev']['cache_on'] = FALSE;
$db['dsn_esfhouse_dev']['cachedir'] = '';
$db['dsn_esfhouse_dev']['char_set'] = 'gbk';
$db['dsn_esfhouse_dev']['dbcollat'] = 'gbk';
$db['dsn_esfhouse_dev']['swap_pre'] = '';
$db['dsn_esfhouse_dev']['autoinit'] = FALSE;
$db['dsn_esfhouse_dev']['stricton'] = FALSE;
}elseif(GB_CITY=='hf'){ }elseif(GB_CITY=='hf'){
$db['dsn_esfhouse']['hostname'] = $conf_db_host; $db['dsn_esfhouse']['hostname'] = $conf_db_host;
$db['dsn_esfhouse']['username'] = 'root'; $db['dsn_esfhouse']['username'] = 'root';
......
...@@ -17,6 +17,8 @@ class MY_Model extends CI_Model ...@@ -17,6 +17,8 @@ class MY_Model extends CI_Model
$this->db_esfhouse = $this->load->database('dsn_esfhouse',true); $this->db_esfhouse = $this->load->database('dsn_esfhouse',true);
$this->db_esfhousebak = $this->load->database('dsn_esfhousebak',true); $this->db_esfhousebak = $this->load->database('dsn_esfhousebak',true);
$this->db_esfhousedev = $this->load->database('dsn_esfhouse_dev',true);
$this->db_esfuserdev = $this->load->database('dsn_esfuser_dev',true);
$this->load->library('server',array('appName'=>NS_SELL,'strCheckMethod'=>"",'returnMethod'=>"ary",'returnCharSet'=>"gbk"),'server_sell'); $this->load->library('server',array('appName'=>NS_SELL,'strCheckMethod'=>"",'returnMethod'=>"ary",'returnCharSet'=>"gbk"),'server_sell');
...@@ -304,6 +306,14 @@ class MY_Model extends CI_Model ...@@ -304,6 +306,14 @@ class MY_Model extends CI_Model
$this->db = $this->db_esfhousebak; $this->db = $this->db_esfhousebak;
break; break;
case 'esfhousedev':
$this->db = $this->db_esfhousedev;
break;
case 'esfuserdev':
$this->db = $this->db_esfuserdev;
break;
default: default:
$this->db = $this->db_esf; $this->db = $this->db_esf;
} }
......
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
* @author cxf
*/
class Dev_User_class
{
public function __construct()
{
}
function user_login($result,$password='',$telno='',$name='')
{
//隐藏手机号部分数字
$pattern = "/(1\d{1,2})\d\d(\d{0,3})/";
$replacement = "\$1*****\$3";
$telno2 = preg_replace($pattern, $replacement, trim($telno));
$showname = $telno2 ? $telno2 : $name ;
$CI = &get_instance();
$CI->load->model('user_model');
$esfmesnum = $CI->user_model->getmessagenumbyuidwd($result);
if($telno=='')
{
$temp = $CI->user_model->getuserdetailUcenter($result);
$telno = $temp['telno'];
}
$password_encrypt = passport_encrypt($password);
//设置COOKIE
vbsetcookie("esfuserid","",1);
vbsetcookie("esfpassword","",1);
vbsetcookie("esfstyleid","",1);
vbsetcookie("esfusertelno","",1);
vbsetcookie("esfusername","",1);
vbsetcookie("esfshowname","",1);
vbsetcookie("esfmesnum","",1);
vbsetcookie("ckinfo","",1);
vbsetcookie("sessionhash","",1);
vbsetcookie("esfuserid",$result);
vbsetcookie("esfpassword",$password);
vbsetcookie("esfusername",$name);
vbsetcookie("esfusertelno",$telno);
vbsetcookie("esfusercity",GB_CITY);
vbsetcookie('lastvisit','',0);
vbsetcookie("esfshowname",$showname);
vbsetcookie("esf".GB_CITY."mesnum",$esfmesnum);
//逐步替代password,最终去掉password的cookie,增加安全性
vbsetcookie("esf_encrypt",$password_encrypt);
//登录SESSION
$array = array( 'esfuserid'=>$result , 'esfpassword'=>$password ,'esfusername'=>$name , 'esfusertelno'=>$telno ,'esfusercity'=>GB_CITY,'esfshowname'=>$showname,'esfmesnum'=>$esfmesnum);
$CI->load->library('session');
$CI->session->set_userdata($array);
/* 登录日志记录 */
$CI->load->model('user_statistic_model');
//初始化用户信息
$CI->user_statistic_model->set_uid($result);
$CI->user_statistic_model->set_city(GB_CITY);
//提交登录信息
$CI->user_statistic_model->sub_login_log();
$CI->load->model('user_model');
//查询上次登录时间
$last_logintime = $CI->user_model->getuserdetailUcenter($result);
if(date("Y-m-d",$last_logintime['lastlogintime']) != date("Y-m-d"))
{
//查询小区是否有新房源
$msg1 = $CI->user_model->getnewblockhouse($result,$last_logintime['lastlogintime']);
$CI->load->library("apply_class");
if(is_array($msg1) && !empty($msg1))
{
$string = implode(',',$msg1);
//发送消息
$subject = '您关注的小区有新的房源。';
$msg = '您关注的小区“'.$string.'”有新的房源发布,<a href="'.USER_CENTER.'user/blocklist">点击查看</a>。';
$CI->apply_class->send_systemmsg($result,$subject,$msg,2,GB_CITY);
}
//查询找房条件是否有新房源
$result = $CI->user_model->getnewtjhouse($result,$last_logintime['lastlogintime']);
if($result == 1)
{
//发送消息
$subject = '您关注的找房条件有新的房源。';
$msg = '您关注的找房条件有新的房源。<a href="'.USER_CENTER.'user/sell_condition">点击查看</a>。';
$CI->apply_class->send_systemmsg($result,$subject,$msg,2,GB_CITY);
}
}
return 1;
}
}
\ No newline at end of file
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
class dev_block_model extends MY_Model
{
function __construct()
{
parent::__construct();
$this->memkey='block'.GB_CITY;
}
/**
* 获取街道名称
* @param type $streetid
* @return string
*/
function getstreetname($streetid)
{
$key = $this->memkey.'_getstreetname_'.$streetid;
if($this->input->get('update') == 1)
{
$this->memcached_class->delete($key);
}
$return = $this->memcached_class->get($key);
if(isset($_GET['wmc'])){
var_dump($this->memcached_class); exit;
}
if( empty($return) )
{
$return = $this->get_data(array('form_name' => 'street','where'=>array('id'=>$streetid),'select'=>array('streetname')),'esfhousebak');
$this->memcached_class->add($key, $return,3600);
}
if(!empty($return[0]))
{
return $return[0];
}else{
return 0;
}
}
/**
* 获取地铁站点名称
* @param type $stid
* @return string
*/
function getstname($stid)
{
$key = $this->memkey.'getstname'.$stid;
if($this->input->get('update') == 1)
{
$this->memcached_class->delete($key);
}
$return = $this->memcached_class->get($key);
if( empty($return) )
{
$return = $this->get_data(array('form_name' => 'traffic','where'=>array('bid'=>$stid),'select'=>array('station')),'esfhousebak');
$this->memcached_class->add($key, $return,3600);
}
if(!empty($return[0]['station']))
{
return $return[0]['station'];
}else{
return 0;
}
}
/**
* 获取小区详细信息
* @param array $blockname
* @return array
*/
function getblockdetailbyname($blockname,$select)
{
$key = $this->memkey.'getblockdetailbyname'.$blockname.serialize($select);
if($this->input->get('update') == 1)
{
$this->memcached_class->delete($key);
}
$block = $this->memcached_class->get($key);
if( empty($block) )
{
$block = $this->get_data(array('form_name' => 'block','where'=>array('blockname'=>trim($blockname)),'where'=>array('esta'=>2),'select'=>$select),'esfhousebak');
$this->memcached_class->add($key, $block,3600);
}
if(!empty($block[0]))
{
return $block[0];
}
else
{
return 0;
}
}
/**
* 获取板块详细信息
* @param array $blockname
* @return array
*/
function getstreetdetailbyname($streetname,$select)
{
$key = $this->memkey.'getstreetdetailbyname'.$streetname.serialize($select);
if($this->input->get('update') == 1)
{
$this->memcached_class->delete($key);
}
$street = $this->memcached_class->get($key);
if( empty($street) )
{
$street= $this->get_data(array('form_name' => 'street','where'=>array('streetname'=>trim($streetname)),'select'=>$select),'esfhousebak');
$this->memcached_class->add($key, $block,3600);
}
if(!empty($street[0]))
{
return $street[0];
}
else
{
return 0;
}
}
/**
* 获取地铁站点名称
* @param type $stid
* @return string
*/
function getline()
{
$key = $this->memkey.'getline';
if($this->input->get('update') == 1)
{
$this->memcached_class->delete($key);
}
$arr_list_line = $this->memcached_class->get($key);
if(empty($arr_list_line) )
{
$sql = "select bid,sid,station,line,tofor from traffic where type=1 ORDER BY line ASC , sid ASC ";
$query = $this->db_esfhousebak->query($sql);
$arr = $query->result_array();
$num = count($arr);
if(!empty($arr)){
for ($i=0;$i<$num;$i++){
$bid = $arr[$i]['bid'];
$sid = $arr[$i]['sid'];
$line = $arr[$i]['line'];
$station_info [$line]['bid']= $arr[$i]['bid'];
$station_info [$line]['line']= $arr[$i]['line'];
$station = $arr[$i]['station'];
if($arr[$i]['tofor'] == 1){
$station_info[$line]['bus_up'][$sid] = $station;
}elseif($arr[$i]['tofor'] == 2){
$station_info[$line]['bus_down'][$sid] = $station;
}elseif($arr[$i]['tofor'] == 3){
$station_info[$line]['single'][$sid] = $station;
}
}
}
$arr_list_line = array();
$j = 1;
if($station_info){
foreach($station_info as $key => $value){
if(isset($value['bus_up']) && $value['bus_up']){
$st_station = csubstr2(array_shift($value['bus_up']),8);
$end_station = csubstr2(array_pop($value['bus_up']),8);
$arr_list_line[$key.'1'] = '('.$st_station.'-'.$end_station.')';
$arr_list_line[$j] = $key;
$arr_list_line[$key.'1k'] = $j;
$arr_list_line[$j.'tf'] = 1;
$j++;
}
if(isset($value['bus_down']) && $value['bus_down']){
$st_station = csubstr2(array_shift($value['bus_down']),8);
$end_station = csubstr2(array_pop($value['bus_down']),8);
$arr_list_line[$key.'2'] = '('.$st_station.'-'.$end_station.')';
$arr_list_line[$j] = $key;
$arr_list_line[$key.'2k'] = $j;
$arr_list_line[$j.'tf'] = 2;
$j++;
}
if(isset($value['single']) && $value['single']){
$st_station = csubstr2(array_shift($value['single']),8);
$end_station = csubstr2(array_pop($value['single']),8);
$arr_list_line[$key.'3'] = '('.$st_station.'-'.$end_station.')';
$arr_list_line[$j] = $key;
$arr_list_line[$key.'3k'] = $j;
$arr_list_line[$j.'tf'] = 3;
$j++;
}
}}
$this->memcached_class->add($key, $arr_list_line,3600);
}
return $arr_list_line;
}
/**
* 获取小区的统计信息
* @param int $id 小区id号
* @param date $updateDate 日期
* @return array
*/
public function getBlockHouseNumById($id, $updateDate = '') {
//默认取前一天的数据
if ($updateDate == '') {$updateDate = date('Y-m-d');}
$key = $this->memkey.'block_count_'.$updateDate.'_'.$id;
if($this->input->get('update') == 1)
{
$this->memcached_class->delete($key);
}
$arrBlockCountDetail = $this->memcached_class->get($key);
if(!isFullArray($arrBlockCountDetail))
{
$arrBlockCountDetail = $this->get_data(array('form_name' => 'block_count','where'=>array('blockid'=>$id,'updatedate'=>$updateDate)),'esfhousebak');
$this->memcached_class->add($key, $arrBlockCountDetail,600);
}
return $arrBlockCountDetail;
}
public function getBlockPriceById($id) {
//默认取前一天的数据
//if ($updateDate == '') {$updateDate = date('Y-m-d');}
$key = $this->memkey.'block_count_'.'_'.$id;
if($this->input->get('update') == 1)
{
$this->memcached_class->delete($key);
}
$arrBlockCountDetail = $this->memcached_class->get($key);
if(!isFullArray($arrBlockCountDetail))
{
$arrBlockCountDetail = $this->get_data(array('form_name' => 'block_price','where'=>array('blockid'=>$id)),'esfhousebak');
//print_r($arrBlockCountDetail);die;
$this->memcached_class->add($key, $arrBlockCountDetail,600);
}
return $arrBlockCountDetail;
}
/**
* 获取小区详细信息
* @param type $blockid
* @return array
*/
function getblockdetail($blockid,$select)
{
$block = $this->get_data(array('form_name' => 'block','where'=>array('id'=>$blockid),'select'=>$select),'esfhousebak');
if(!empty($block[0]))
{
return $block[0];
}else{
return 0;
}
}
/**
* 获取小区详细信息
* @param array $blockids
* @return array
*/
function getarrayblockdetail($blockids,$select)
{
$block = $this->get_data(array('form_name' => 'block','where_in'=>array('id',$blockids),'where'=>array('esta'=>2),'select'=>$select),'esfhousebak');
return $block;
}
/**
* 获取小区附近小区
* @param arary $blockid 查询的小区编号
* @param array $hidden_bid_arr 应该排除的小区
* @param int $num 查询个数
* @return array
*/
function getsearchBlockNearly( $blockid , $hidden_bid_arr , $num = 4 )
{
//查询到的小区编号
$serach_ids = '';
$blockid = intval($blockid);
if( $blockid <= 0)
{
return $serach_ids;
}
//获取小区信息
$Info = $this->getblockdetail( $blockid , array('id','b_map_x','b_map_y'));
if( $Info['id'] > 0 )
{
$b_map_x = $Info['b_map_x'];
$b_map_y = $Info['b_map_y'];
$map_x_min = $b_map_x > 0 ? $b_map_x - 0.01 : 0 ;
$map_x_max = $b_map_x > 0 ? $b_map_x + 0.01 : 0 ;
$map_y_min = $b_map_y > 0 ? $b_map_y - 0.01 : 0 ;
$map_y_max = $b_map_y > 0 ? $b_map_y + 0.01 : 0 ;
//需要过滤小区个数,多查num+count(排除小区)个小区
$search_num = $num + count($hidden_bid_arr);
$blockNearly = $this->getBlockInfoByMap( $map_x_min , $map_x_max , $map_y_min , $map_y_max , $search_num );
if(is_array($blockNearly)&& !empty($blockNearly) )
{
$i = 0;
foreach($blockNearly as $key => $vlaue)
{
if( $i >= $num)
{
break;
}
//过滤需要隐藏的小区本身
if( !in_array( $vlaue['id'] , $hidden_bid_arr) )
{
//查询出来的小区ID
$serach_ids .= $serach_ids != '' ? ','.$vlaue['id'] : $vlaue['id'];
$i++;
}
}
}
}
return $serach_ids;
}
/**
*根据地图坐标获取小区
*@param float $map_x_min 最要的经度坐标
*@param float $map_x_max 最大的经度坐标
*@param float $map_y_min 最小的纬度坐标
*@param float $map_y_max 最大的纬度坐标
*@param int $count 获取的小区的个数
*@return array 信息数组
*@author xue
*@since 2013-12-2
**/
public function getBlockInfoByMap( $map_x_min , $map_x_max , $map_y_min , $map_y_max , $count=8)
{
$cond_where = " WHERE b_map_x >= '".$map_x_min."' AND b_map_x <= '".$map_x_max."' AND b_map_y >= '".$map_y_min."' AND b_map_y <= '".$map_y_max."' AND esta = 2";
$cond_limit = " LIMIT 0, ".intval($count);
$cond_order = ' ORDER BY id DESC ';
$sql = " SELECT id,blockname FROM block ";
$sql .= $cond_where . $cond_order . $cond_limit;
$query = $this->db_esfhousebak->query($sql);
$blockInfo = $query->result_array();
return $blockInfo;
}
/**
*找出小区最高最低价
*@param int $school 学校id
*@param array $blockArr 小区数组
*@return array 信息数组
*@author xue
**/
public function getBlockPrice($school,$blockArr)
{
$key = $this->memkey.'get_school_block_price_'.$school;
if($this->input->get('update') == 1)
{
$this->memcached_class->delete($key);
}
$price = $this->memcached_class->get($key);
if(empty($price) )
{
if(is_array($blockArr)&&!empty($blockArr))
{
$blockPrice = $this->getarrayblockdetail($blockArr,array('averprice'));//block_model要改成this
$maxPrice = $this->getPrice($blockPrice,'max');
$minPrice = $this->getPrice($blockPrice,'min');
$price = array('min'=>$minPrice,'max'=>$maxPrice);
}
$this->memcached_class->add($key, $price,3600);
}
return $price;
}
/**
*找到最低最高价
*@param string $type 最高或最低
*@param array $blockPrice 小区数组
*@return array 信息数组
*@author xue
**/
private function getPrice($blockPrice,$type)
{
$re = 0;
if($blockPrice)
{
foreach($blockPrice as $k=>$b)
{
if($type == 'max')
{
$x = $b['averprice'] > $re;
}
if($type == 'min')
{
$x = $b['averprice'] < $re;
}
if($k == 0)
{
$re = $b['averprice'];
}
if( $x && intval($b['averprice']) )
{
$re = $b['averprice'];
}
}
return $re;
}
else
{
return false;
}
}
}
\ No newline at end of file
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class dev_broker_model extends MY_Model
{
function __construct()
{
parent::__construct();
}
/**
* ȡ
* @param type $uid
* @return array
*/
function getbrokerdetail($uid)
{
$key = $this->memkey.'_getbrokerdetail_'.$uid;
if($this->input->get('update') == 1)
{
$this->memcached_class->delete($key);
}
$broker = $this->memcached_class->get($key);
if( empty($broker) )
{
$broker = $this->get_data(array('form_name' => 'broker','where'=>array('uid'=>$uid),'select'=>array('uid','truename','agentcode','username','telno','smallphoto')),'esfhousebak');
if(isset($broker[0]['agentcode']) && !empty($broker[0]['agentcode']))
{
$agent = $this->get_data(array('form_name' => 'agency','where'=>array('agentcode'=>$broker[0]['agentcode']),'select'=>array('agid','agentshortname')),'esfhousebak');
$broker[0]['agentshortname'] = $agent[0]['agentshortname'];
$broker[0]['agid'] = $agent[0]['agid'];
}
$this->memcached_class->add($key, $broker,3600);
}
if(!empty($broker[0]))
{
return $broker[0];
}else{
return 0;
}
}
}
\ No newline at end of file
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Dev_House_model extends MY_Model
{
function __construct()
{
parent::__construct();
$this->load->model("house_statistic_model");
}
/**
* 验证房源的可刷新次数
* @param type $uid,房源id $id
* @return array
*/
function yzrefrshnum($uid,$id,$tbl='sell')
{
//获得可刷新次数
//flag=1代表上传图片刷新, 2代表付费刷新
$num1 = $this->get_data(array('form_name' => 'personal_refresh','where'=>array('uid'=>$uid,'rowid'=>$id,'tbl'=>$tbl,'esta'=>1,'flag'=>1),'select'=>array('refresh_num')),'esfbak');
$num2 = $this->get_data(array('form_name' => 'personal_refresh','where'=>array('rowid'=>$id,'tbl'=>$tbl,'flag'=>2,'esta'=>1,'begin_time <'=>time(),'end_time >'=>time()),'select'=>array('refresh_num')),'esfbak');
if(!empty($num1[0]['refresh_num']) && !empty($num2[0]['refresh_num']))
{
$num = $num1[0]['refresh_num']+$num2[0]['refresh_num'];
}elseif(!empty($num1[0]['refresh_num']))
{
$num = $num1[0]['refresh_num'];
}elseif(!empty($num2[0]['refresh_num']))
{
$num = $num2[0]['refresh_num'];
}
if(!empty($num))
{
return $num;
}else{
return 0;
}
}
/**
* 验证房源的可刷新次数
* @param type $uid,房源id $id
* @return array
*/
function yzrefrsh($uid,$id,$tbl='sell',$flag=1)
{
//获得可刷新次数
$result = $this->get_data(array('form_name' => 'personal_refresh','where'=>array('uid'=>$uid,'rowid'=>$id,'tbl'=>$tbl,'esta'=>1),'select'=>array('id')),'esfbak');
if(!empty($result))
{
return $result;
}else{
return 0;
}
}
/**
* 验证房源的可刷新次数
* @param $telno 手机号,$arr 匹配信息,$tbl 表
* @return array
*/
function yzsamehouse($telno , $arr , $tbl = 'sell')
{
$total_num = 0;
if( in_array( $tbl , array('sell','rent') ) && !empty($telno) )
{
$sql = "SELECT id FROM $tbl ";
$where_cond = " WHERE esta = '1' AND infofrom = '1' AND ischarge = '0' AND telno='".$telno."'";
if(is_array($arr) && !empty($arr))
{
foreach($arr as $key=>$value)
{
$value = addslashes(strip_tags($value));
$where_cond .= " AND ".$key." = '".$value."'";
}
}
//echo '<!--'.$sql . $where_cond.'-->';
$query = $this->db_esfhousebak->query($sql . $where_cond);
$result = $query->result_array();
if( isset($result[0]['id']) )
{
$return = 1;
}else{
$return = 0;
}
}
return $return;
}
/**
* 添加房源的可刷新次数
* @param type $uid,房源id $id,添加刷新次数 $num,城市 $city_name
* @return array
*/
function addrefrshnum($uid,$id,$tbl='sell',$num,$city_name,$flag=1)
{
//验证是否有刷新次数
$result = $this->yzrefrsh($uid,$id,$tbl,$flag);
if($result >0 )
{
$this->updaterefrshnum($uid,$id,$num,$tbl,$flag,$city_name);
}
else
{
$arr['uid'] = $uid;
$arr['rowid'] = $id;
$arr['tbl'] = $tbl;
$arr['refresh_num'] = $num;
$arr['cityname'] = $city_name;
//设置表
$this->house_model->set_table('personal_refresh');
//过滤表结构
$result = $this->house_model->add($arr,'esf');
}
}
/**
* 刷新房源更新时间
* @param type $telno 手机号码 $validcode 验证码
* @return string
*/
function updatehouse($id,$tbl,$up)
{
if( $id > 0)
{
$arr = array( 'id' => $id );
$this->set_table($tbl);
$result = $this->save($arr,$up,'esfhouse');
if($tbl=='rent')
{
$housedetail = $this->get_data(array('form_name' => $tbl,'where'=>array('id'=>$id,'infofrom'=>'1'),'select'=>array('telno','infotype')),'esfhousebak');
$telno =$housedetail[0]['telno'];
$infotype =$housedetail[0]['infotype'];
if($infotype==1)
{
$ip =get_ip();
if(isset($up) && $up['esta']==2)
{
$arr = array( 'rowid' => $id );
$this->set_table('rent_of_zhizu');
$this->save($arr,array('status'=>2),'esfhouse');
//echo "http://mtapi.house365.com/?method=zhizu.rentRefreshHouse&city=".GB_CITY."&id=".$id."&telno=".$telno."&fromzhizu=2&ip=".$ip."&sell_status=2";die;
get_api("http://mtapi.house365.com/?method=zhizu.rentRefreshHouse&city=".GB_CITY."&id=".$id."&telno=".$telno."&fromzhizu=2&ip=".$ip."&sell_status=2");
if(GB_CITY=='nj')
{
$value_url ="http://mtapi.house365.com/?method=zhizu.rentRefreshHouse&city=".GB_CITY."&id=".$id."&telno=".$telno."&fromzhizu=2&ip=".$ip."&sell_status=2";
//记录日志
$msg = "************************************************ \n";
$msg .= date('Y-m-d H:i:s').var_export($value_url,true)." \n";
$log = dirname(__FILE__)."/log/house_update_record_".$_SERVER['REMOTE_ADDR'].'.log';
file_put_contents($log,$msg,FILE_APPEND );
}
}
else
{
get_api("http://mtapi.house365.com/?method=zhizu.rentRefreshHouse&city=".GB_CITY."&id=".$id."&telno=".$telno."&fromzhizu=2&ip=".$ip."&sell_status=1");
if(GB_CITY=='nj')
{
$value_url ="http://mtapi.house365.com/?method=zhizu.rentRefreshHouse&city=".GB_CITY."&id=".$id."&telno=".$telno."&fromzhizu=2&ip=".$ip."&sell_status=1";
//记录日志
$msg = "************************************************ \n";
$msg .= date('Y-m-d H:i:s').var_export($value_url,true)." \n";
$log = dirname(__FILE__)."/log/house_update_record_".$_SERVER['REMOTE_ADDR'].'.log';
file_put_contents($log,$msg,FILE_APPEND );
}
}
}
}
}
return $result;
}
/**
* 再发布房源
* @param type $telno 手机号码 $validcode 验证码
* @return string
*/
function republishhouse($id,$tbl,$up,$conf_city)
{
if( $id > 0)
{
// 2017-3-28 添加再发布匹配小区图片 功能 --- start ----->
$housedetail_pic_info = $this->get_data(array('form_name' => $tbl,'where'=>array('id'=>$id,'infofrom'=>'1'),'select'=>array('pic1','blockid','telno')),'esfhousebak');
if(empty($housedetail_pic_info['0']['pic1']))
{
$blockid =$housedetail_pic_info['0']['blockid'];
$pic_url_lm = $this->get_block_pic_by_type($blockid , 52);
if( $pic_url_lm != '')
{
$filename = $pic_url_lm;
}
else
{
$filename = $this->get_block_pic_by_type( $blockid , 0);
}
if( $filename != '')
{
$title = '';
$sort = 1;
$blockid = $blockid;
$createtime = time();
$upload_name = get_upload_tblname($tbl,$id);
$sql = "INSERT INTO $upload_name(`tbl`,`rowid`,`position`,`filename`,`title` ,`blockid`,`sort`,`createtime`,`isfrom`) VALUES('$tbl',$id,'pic1','$filename','$title','$blockid','$sort','$createtime','1')";
//echo $sql;die;
$this->db_esfhouse->query($sql);
$sql = "UPDATE $tbl SET pic1 = '".$filename."',lucupdatetime=lucupdatetime+1 WHERE id = '".$id."' ";
//echo $sql;die;
$this->db_esfhouse->query($sql);
}
}
// 2017-3-28 添加再发布匹配小区图片 功能 --- end ----->
$arr = array( 'id' => $id );
$this->set_table($tbl);
$result = $this->save($arr,$up,'esfhouse');
if($conf_city=='nj' || $conf_city=='wh' || $conf_city=='hf' || $conf_city=='wx')
{
if($tbl=='sell')
{
$tbl_tmp =0;
}
else
{
$tbl_tmp =1;
}
$again_date =date('Y-m-d');
$again_info =$this->get_data(array('form_name' => 'house_again_publish_stat','where'=>array('ctime'=>$again_date,'source'=>'0','type'=>$tbl_tmp),'select'=>array('id','num')),'esfhousebak');
if(!empty($again_info[0]['num']))
{
$this->db_esfhouse->query("update house_again_publish_stat set num=num+1 where ctime='$again_date' and source=0 and type=$tbl_tmp");
}
else
{
$this->db_esfhouse->query("insert into house_again_publish_stat (num,type,source,ctime) values ('1','$tbl_tmp','0','$again_date')");
}
############# 2018-9-5 再发布 添加再审核 ###########
$ctime_now =time();
$telno =$housedetail_pic_info['0']['telno'];
$this->db_esfhouse->query("insert into house_again_check (rowid,tbl,telno,ctime) values ($id,'$tbl',$telno,'$ctime_now')");
############# 2018-9-5 再发布 添加再审核 ###########
############# 2016-7-26 再发布删除 sell_delete_app_person start ###########
$this->db_esfhouse->query("DELETE FROM sell_delete_app_person WHERE tbl='$tbl' AND rowid = $id");
############# 2016-7-26 再发布删除 sell_delete_app_person end ###########
############2016-12-21 再发布传数据给直租######################
if($tbl=='rent')
{
$housedetail = $this->get_data(array('form_name' => $tbl,'where'=>array('id'=>$id,'infofrom'=>'1'),'select'=>array('telno')),'esfhousebak');
$telno =$housedetail[0]['telno'];
$ip =get_ip();
if(isset($up) && $up['esta']==1)
{
$arr = array( 'rowid' => $id );
$this->set_table('rent_of_zhizu');
$this->save($arr,array('status'=>0),'esfhouse');
get_api("http://mtapi.house365.com/?method=zhizu.rentRefreshHouse&city=".GB_CITY."&id=".$id."&telno=".$telno."&fromzhizu=2&ip=".$ip."&sell_status=0");
}
}
$value_url ="http://mtapi.house365.com/?method=zhizu.rentRefreshHouse&city=".GB_CITY."&id=".$id."&telno=".$telno."&fromzhizu=2&ip=".$ip."&sell_status=0";
//记录日志
$msg = "************************************************ \n";
$msg .= date('Y-m-d H:i:s').var_export($value_url,true)." \n";
$log = dirname(__FILE__)."/log/house_republish_record_".$_SERVER['REMOTE_ADDR'].'.log';
file_put_contents($log,$msg,FILE_APPEND );
############2016-12-21 再发布传数据给直租######################
}
}
//再发布更新已经激活的同样条件的房源
$housedetail = $this->get_data(array('form_name' => $tbl,'where'=>array('id'=>$id,'infofrom'=>'1'),'select'=>array('blockshowname','buildarea','price','floor','telno')),'esfhousebak');
if(!empty($housedetail[0]['telno']))
{
//更新此条件下其他房源
$this->db_esfhouse->query("update $tbl set esta=-5,note='系统打为重复' where telno='".$housedetail[0]['telno']."' AND esta = '1' AND infofrom = '1' AND ischarge!='1' AND id!=$id AND blockshowname='".$housedetail[0]['blockshowname']."' AND buildarea='".$housedetail[0]['buildarea']."' AND floor='".$housedetail[0]['floor']."' AND updatetime>'".strtotime(date('Y-m-d'))."'");
$this->db_esfhouse->query("update $tbl set esta=2,note='系统打为失效' where telno='".$housedetail[0]['telno']."' AND esta = '1' AND infofrom = '1' AND ischarge!='1' AND id!=$id AND blockshowname='".$housedetail[0]['blockshowname']."' AND buildarea='".$housedetail[0]['buildarea']."' AND floor='".$housedetail[0]['floor']."' AND updatetime<'".strtotime(date('Y-m-d'))."'");
}
return $result;
}
function get_block_pic_by_type($blockid , $bi_type)
{
$where_cond = "WHERE bi_blockid = '".$blockid."'";
if( $bi_type > 0 )
{
$where_cond .= " AND bi_type = '".$bi_type."' limit 1";
}
else
{
$where_cond .= " AND bi_type IN (51,52,53) limit 1";
}
$sql = "SELECT bi_img as pic FROM block_img ".$where_cond .$order_cond;
$query = $this->db_esfhousebak->query($sql);
$result = $query->result_array();
return $result[0]['pic'];
}
/**
* 更新可用刷新次数
* @param type $telno 手机号码 $validcode 验证码 $num刷新次数 $tbl 表
* @return string
*/
function updaterefrshnum($uid,$id,$num,$tbl='sell',$flag=1,$city = '')
{
if(!empty($city))
{
$query = $this->db_esf->query("UPDATE `personal_refresh` SET `refresh_num` = '$num' WHERE `rowid` = '$id' AND `uid` = '$uid' AND `tbl` = '$tbl' AND `flag` = '$flag' AND `cityname`='$city'");
if(!$query)
{
file_put_contents('test.log',"edit:会员id=".$uid." 房源id=".$id." 刷新次数=".$num." 城市=".$city." 房源类型tbl=".$tbl." 标记flag=".$flag." 记录时间=".date('Y-m-d H:i:s')."\r\n",FILE_APPEND);
}
}
else
{
$query = $this->db_esf->query("UPDATE `personal_refresh` SET `refresh_num` = '$num' WHERE `rowid` = '$id' AND `uid` = '$uid' AND `tbl` = '$tbl' AND `flag` = '$flag'");
}
return 1;
}
/**
* 根据用户id获取房源数量
* @param type $uid
* @return array
*/
function gethousenumbyuid( $uid , $tbl='sell' , $esta=0)
{
if($esta == 1)
{
$housenum = $this->get_data(array('form_name' => $tbl,'where'=>array('uid'=>$uid,'esta'=>'1','infofrom'=>'1'),'select'=>array('count(id) as num')),'esfhousebak');
}else{
$housenum = $this->get_data(array('form_name' => $tbl,'where'=>array('uid'=>$uid,'esta !='=>'4','infofrom'=>'1'),'select'=>array('count(id) as num')),'esfhousebak');
}
//print_r($housenum);
return $housenum[0]['num'];
}
/**
* 根据用户id获取房源信息
* @param type $uid
* @return array
*/
function gethousebyuid($uid,$tbl='sell',$select,$offset=0,$pagesize=0)
{
$this->load->model("pic_model");
$housearray = $this->get_data(array('form_name' => $tbl,'where'=>array('uid'=>$uid,'infofrom'=>'1','esta !='=>4),'select'=>$select,'order_by'=>'creattime desc','limit'=>$offset,'offset'=>$pagesize),'esfhousebak');
//echo $this->db->last_query();
$day_now = date('Y-m-d');
if(GB_CITY=='nj'){
//获取数组的个数,再把图片的数量插入数组中
$housearray_number =count($housearray);
for($i=0;$i<$housearray_number;$i++)
{
$sell_house_id =$housearray[$i]['id'];
$this->load->helper('function');
$uploadtbl = get_upload_tblname($tbl,$sell_house_id);
$pic_number = $this->pic_model->getPicNum($tbl,$sell_house_id,$uploadtbl);
$housearray[$i]['pic_num'] =$pic_number;
$housearray[$i]['city_name']=GB_CITY;
//计算当前房源是否参与推广,以及参与推广套餐 最后的
//被删除或者审核中的 则不计算,直接跳过
if($tbl == 'sell'){
$house_type = 1;
}else{
$house_type = 2;
}
$now_time = time();
$promote = $this->db_esfhousebak->from('personal_house_promote')->where(array('house_id'=>$sell_house_id,'house_type'=>$house_type,'status'=>1))->where('start_time <=',$now_time)->where('end_time >=',$now_time)->order_by('end_time','desc')->limit(1)->get()->row_array();
$housearray[$i]['between_day'] ='';
$housearray[$i]['$between_hour']='';
$housearray[$i]['between']='';
if($promote && $promote['order_id']){
$package_type = $promote['package_type'];
$order = $this->db_esfhousebak->from('personal_house_orders')->where(array('id'=>$promote['order_id'],'pay_status'=>1))->where('pay_time <>','')->get()->row_array();
//$pay_time = $order['pay_time'];
//$hours = date('H:i:s',$pay_time);
if($order){
//$endT = date('Y-m-d H:i:s',strtotime('-1 day',$promote['end_time']));
//$endT = $endtime.' '.$hours;
$day_overdue = $promote['end_time'];
if($day_overdue >time() ){
$between_time = $day_overdue-time();//相差的 秒数
$between_day = floor($between_time/24/3600);//相差天数
$h = ($between_time%(3600*24))/3600;
$between_hour = floor($h);
$housearray[$i]['between_day'] = $between_day;
$housearray[$i]['between_hour']= $between_hour;
if($between_day<1 ){
if($between_hour<1){
$housearray[$i]['between'] = '剩余不足1小时';
}else{
$housearray[$i]['between'] = '剩余'.$between_hour.'小时';
}
}else{
if($between_hour>1){
$housearray[$i]['between']='剩余'.$between_day.'天'.$between_hour.'小时';
}else{
$housearray[$i]['between']='剩余'.$between_day.'天';
}
}
}
}
}
}
}
return $housearray;
}
/**
* 根据所传数组获取房源信息
* @param type $where
* @return array
*/
function gethousebywhere($where,$tbl='sell',$select,$offset=0,$pagesize=0)
{
$housearray = $this->get_data(array('form_name' => $tbl,'where'=>$where,'select'=>$select,'order_by'=>'updatetime desc','limit'=>$offset,'offset'=>$pagesize),'esfhousebak');
return $housearray;
}
/**
* 获取房源联系人手机号
* @param $house_id
*/
function getHouseTel($house_id,$tbl='sell_ext'){
$telarray = $this->get_data(array('form_name' => $tbl,'where'=>array('house_id'=>$house_id),'select'=>array('telno')),'esfhousebak');
return empty($telarray) ? '' : $telarray[0]['telno'];
}
/**
* 根据所传数组获取房源信息
* @param type $where
* @return array
*/
function get_house_num_by_where($where,$tbl='sell')
{
$house_info = $this->get_data(array('form_name' => $tbl,'where'=>$where,'select'=>array('count(id) as num')),'esfhousebak');
$house_num = isset($house_info[0]['num']) ? $house_info[0]['num'] : 0;
return $house_num;
}
/**
* 更改房源的uid
* @param type $uid
* @return array
*/
function updatehouseuid( $uid , $newuid , $tbl = 'sell')
{
$uid = intval($uid);
$newuid = intval($newuid);
if( $uid > 0 && $newuid > 0 && in_array( $tbl , array('sell','rent') ) )
{
$sql = "UPDATE $tbl SET uid = '$newuid' WHERE uid = '$uid' AND infofrom = '1'";
$this->db_esfhouse->query($sql);
$msg = 1;
}
else
{
$msg = 0;
}
return $msg;
}
/**
* 添加个人房源匹配求购求租信息
* @param string $want_type 求购求租类型(buy/rentwant)
* @param int $want_id 求购求租信息编号
* @param int $want_uid 求购求租人账号
* @param int $match_id 匹配房源编号
* @param int $uid 匹配人账号编号
* @return array 添加结果
*/
public function add_match_info( $want_type , $want_id , $want_uid , $match_id , $uid )
{
if( in_array( $want_type, array('buy','rentwanted') ) )
{
if( $want_type == 'buy')
{
$tbl_want = 'buy';
$tbl_match = 'buy_match';
}
else if( $want_type == 'rentwanted' )
{
$tbl_want = 'rentwanted';
$tbl_match = 'rentwanted_match';
}
//提交的日志数据
$data = array(
'match_id' => $match_id,
'match_uid' => $uid,
'want_id' => $want_id,
'want_uid' => $want_uid,
'infofrom' => 1, //个人
'esta' => 0, //匹配状态
'isread' => 0, //是否已经查看
'creattime' => time()
);
//是否已经添加过匹配
$is_matched = $this->_check_is_matched( $tbl_match , $want_id , $want_uid , $match_id , $uid);
if( !$is_matched )
{
$today_num_matched = $this->_get_matched_num_today( $tbl_match , $want_id , 1 );
//每天10条匹配信息
if( $today_num_matched <= 10)
{
$this->set_table( $tbl_match );//插入数据
$insert_id = $this->add( $data , 'esfhouse' );
if( $insert_id > 0 )
{
//修改求租房源新匹配个数
$sql = " UPDATE $tbl_want SET matched_num = matched_num + 1 WHERE id = ".$want_id;
$query = $this->db_esfhouse->query($sql);
$result['is_ok'] = 1;
$result['insert_id'] = $insert_id;
$result['msg'] = '匹配房源信息插入成功';
}
else
{
$result['is_ok'] = 0;
$result['msg'] = '匹配房源信息插入失败';
}
}
else
{
$result['is_ok'] = 2;
$result['msg'] = '今日个人匹配已达到上限';
}
}
else
{
$result['is_ok'] = 3;
$result['msg'] = '匹配信息已经存在';
}
}
return $result;
}
/**
* 判断某条求购求租的匹配信息是否已经存在
* @param string $tbl_match 房源匹配表(buy/rentwant)
* @param int $want_id 求购求租信息编号
* @param int $want_uid 求购求租用户编号
* @param int $match_id 匹配房源编号
* @param int $match_uid 匹配人账号编号
* @param int $infofrom 匹配房源来源
* @return boolean 是否已经添加(true-已匹配/false)
*/
private function _check_is_matched( $tbl_match , $want_id , $want_uid , $match_id , $match_uid , $infofrom = 1)
{
$is_matched = false;
if( $tbl_match != '')
{
$where_cond = "want_id = '".$want_id."' AND match_id = '".$match_id."'
AND want_uid = '".$want_uid."' AND match_uid = '".$match_uid."' AND infofrom = '".$infofrom."' ";
$this->db_esfhouse->where( $where_cond );
$this->db_esfhouse->from($tbl_match);
$total_num = $this->db_esfhouse->count_all_results();
//echo $this->db_esfhousebak->last_query();
if( $total_num > 0 )
{
$is_matched = true;
}
}
return $is_matched;
}
/**
* 获得某条求购求租房源已匹配的个数
* @param string $tbl_match 房源匹配表(buy/rentwanted)
* @param int $want_id 求购求租信息编号
* @param int $infofrom 匹配房源来源
* @return boolean 是否已经添加(true-已匹配/false)
*/
private function _get_matched_num_today( $tbl_match , $want_id , $infofrom = '')
{
$total_num = 0;
if( $tbl_match != '')
{
$where_cond = "want_id = '".$want_id."' ";
if( intval($infofrom) > 0 )
{
$where_cond .= " AND infofrom = '".$infofrom."' ";
}
//$where_cond .= " AND esta = 0 ";
$this->db_esfhouse->where( $where_cond );
$this->db_esfhouse->from( $tbl_match );
$total_num = $this->db_esfhouse->count_all_results();
//echo $this->db_esfhousebak->last_query();
}
return $total_num;
}
/**
* 获取昨日新增个人有效房源
* @param string $tbl 房源表('sell','rent')
* @return int 新发布个数
*/
function get_personal_house_num_yesterday($tbl)
{
$total_num = 0;
if( in_array( $tbl , array('sell','rent') ) )
{
$yesterday = date('Y-m-d' , strtotime('-1 day'));
$yesterday_time = strtotime($yesterday);
$yesterday_time_end = $yesterday_time + 86400;
$sql = "SELECT id FROM $tbl";
$where_cond = " WHERE esta = '1' AND infofrom = '1' AND creattime >= '".$yesterday_time."'
AND creattime <= '".$yesterday_time_end."' luc";
if( $tbl == 'sell')
{
$total_info = $this->server_sell->query( $sql . $where_cond);
}
else if( $tbl == 'rent')
{
$total_info = $this->server_rent->query( $sql . $where_cond);
}
if( isset($total_info['TOTAL']) )
{
$total_num = intval($total_info['TOTAL']);
}
}
return $total_num;
}
/**
* 获取昨日新增个人有效房源
* @param string $tbl 房源表('sell','rent')
* @param string $offset 偏移量
* @param string $limit 每次显示个数
* @param string $order 排序
* @return array 新发布房源数组
*/
function get_personal_house_yesterday( $tbl , $offset , $limit , $order = 'desc' )
{
$houseinfo = array();
if( in_array( $tbl , array('sell','rent') ) )
{
$yesterday = date('Y-m-d' , strtotime('-1 day'));
$yesterday_time = strtotime($yesterday);
$yesterday_time_end = $yesterday_time + 86400;
$where_cond = " WHERE esta = '1' AND infofrom = '1' AND creattime >= '".$yesterday_time."'
AND creattime <= '".$yesterday_time_end."' ";
$order_cond = " ORDER BY creattime " . $order ;
$limit_cond = " LIMIT ". $offset .",". $limit;
if( $tbl == 'sell')
{
$sql = "SELECT id,uid,infotype,streetid,buildarea,price,buildyear FROM $tbl";
$record_info = $this->server_sell->query( $sql . $where_cond . $order_cond . $limit_cond .' luc');
}
else if( $tbl == 'rent')
{
$sql = "SELECT id,uid,infotype,streetid,buildarea,price,renttype FROM $tbl";
$record_info = $this->server_rent->query( $sql . $where_cond . $order_cond . $limit_cond .' luc');
}
if( isset($record_info['TOTAL']) && isset($record_info['Record']) )
{
$houseinfo = $record_info['Record'];
}
}
return $houseinfo;
}
/**
* 获取房源符合哪些求购信息
* @param string $infotype 房源信息
* @param string $streetid 板块
* @param string $buildarea 建筑面积
* @param string $price 价格
* @param string $buildyear 建筑年代
* @return array 符合条件的个人求购房源
*/
function get_buy_want_by_house ( $infotype , $streetid , $buildarea , $price , $buildyear , $order ='asc')
{
$tbl_want = 'buy';
$nowtime = time();
if( $tbl_want != '')
{
$where_cond = "esta = '1' AND allow_match = '1' AND expiretime > '".$nowtime."' AND
infofrom IN ('0','1') AND infotype = '".$infotype."' AND( street = '".$streetid."' OR street1 = '".$streetid."' OR street2 = '".$streetid."' ) AND buildarea1*0.9 <= '".$buildarea."' AND buildarea2 >= '".$buildarea."' AND price1*0.9 <= '".$price."' AND price2 >= '".$price."' AND buildyear1 <= '".$buildyear."' AND buildyear2 >= '".$buildyear."'";
$this->db_esfhousebak->select('id , uid ,address');
$this->db_esfhousebak->where($where_cond);
$this->db_esfhousebak->order_by( 'creattime' , $order );
$arr_data = $this->db_esfhousebak->get($tbl_want)->result_array();
}
return $arr_data;
}
/**
* 获取房源符合哪些求租信息
* @param string $infotype 房源信息
* @param string $streetid 板块
* @param string $buildarea 建筑面积
* @param string $price 价格
* @param string $renttype 建筑年代
* @return array 符合条件的个人求购房源
*/
function get_rent_want_by_house( $infotype , $streetid , $buildarea , $price , $renttype , $order ='asc')
{
$tbl_want = 'rentwanted';
$nowtime = time();
if( $tbl_want != '')
{
$where_cond = "esta = '1' AND allow_match = '1' AND expiretime > '".$nowtime."' AND
infofrom IN ('0','1') AND infotype = '".$infotype."' AND( street = '".$streetid."' OR street1 = '".$streetid."' OR street2 = '".$streetid."' ) AND buildarea1*0.9 <= '".$buildarea."' AND buildarea2 >= '".$buildarea."' AND price1*0.9 <= '".$price."' AND price2 >= '".$price."' AND renttype = '".$renttype."' ";
$this->db_esfhousebak->select('id , uid , address');
$this->db_esfhousebak->where($where_cond);
$this->db_esfhousebak->order_by( 'creattime' , $order );
$arr_data = $this->db_esfhousebak->get($tbl_want)->result_array();
}
return $arr_data;
}
/**
* 失效过期的求购/求租房源
* @param void
* @return array 符合条件的个人求购房源
*/
function invalid_buy_rentwanted_info( $tbl )
{
$now_time = time();
if( isset ( $tbl ) && in_array( $tbl , array('buy' , 'rentwanted')) )
{
$sql = "UPDATE $tbl SET esta = 2 WHERE expiretime <= '".$now_time."' AND esta IN (0,1)";
$result = $this->db_esfhouse->query($sql);
}
if( $result )
{
$result['is_ok'] = 1;
$result['msg'] = '更新完成';
}
else
{
$result['is_ok'] = 0;
$result['msg'] = '更新失败';
}
return $result;
}
/**
* 更新房源为收费,并更新房源过期时间
* @param string $tbl
* @param string $id
* @return mixed
*/
function updateHouseCharge( $tbl = '1', $id = '0' )
{
$tbl = intval($tbl);
$id = intval($id);
$tableArray = array( 1 => 'sell' , 2 => 'rent');
$tableName = $tableArray[$tbl];
$addTime = 30 * 24 * 60 * 60;
$sql = "UPDATE $tableName SET ischarge = '1',expiretime = expiretime + $addTime , lucupdatetime=". time() ." WHERE id = $id";
$result = $this->db_esfhouse->query($sql);
return $result;
}
/**
* 更新房源为收费,并更新房源过期时间 - 租房个人房源
* @param $id
* @param $days
*/
function updatePersonalHouseCharge($id,$days){
$id = intval($id);
$days = intval($days);
if(!$id || !$days) return false;
$housedetail = $this->get_data(array('form_name' => 'rent','where'=>array('id'=>$id,'infofrom'=>'1'),'select'=>array('expiretime')),'esfhouse');
if(!$housedetail) return false;
$housedetail = $housedetail[0];
$expiretime = 0;
$expiretime_ = time() + $days * 24 * 60 * 60;
if($expiretime_ > $housedetail['expiretime']){
$expiretime = $expiretime_;
}
$edit = array('ischarge'=>'1','lucupdatetime'=>time());
if($expiretime > 0){
$edit['expiretime'] = $expiretime;
}
$this->set_table('rent');
$result = $this->save(array('id'=>$id),$edit,'esfhouse');
return $result;
}
/**
* 房源详情
* @param $house_id
* @param array $fields
* @return array
*/
function getHouse($house_id,$fields=array()){
$fields = $fields ? $fields : array('infofrom');
$housedetail = $this->get_data(array('form_name' => 'rent', 'where' => array('id' => $house_id), 'select' => $fields), 'esfhouse');
return empty($housedetail) ? array() : $housedetail[0];
}
}
\ No newline at end of file
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class dev_push_model extends MY_Model
{
function __construct()
{
parent::__construct();
$this->memkey='mypush'.GB_CITY;
$this->load->model("dev_user_model");
$this->load->model("dev_house_model");
$this->load->model("dev_block_model");
$this->load->model("dev_broker_model");
}
/**
* 查找是否有求购信息加入推送表
* @param type $uid
* @return array
*/
function addbuy($uid,$city=GB_CITY,$sendtime)
{
global $house;
$buydetail = $this->user_model->get_buy_by_uid($uid,0,1,$sendtime);
if(is_array($buydetail) && !empty($buydetail) && $buydetail[0]['infofrom']!=1){
$arr['uid'] = $uid;
$arr['addtime'] = time();
$arr['level'] = 5;
$content['address'] = $buydetail[0]['address'];
$content['infotype'] = $house['infotype'][$buydetail[0]['infotype']];
$content['buildarea'] = $buydetail[0]['buildarea1'].'-'.$buydetail[0]['buildarea2'];
$content['price'] = $buydetail[0]['price1'].'-'.$buydetail[0]['price2'];
$content['buildyear'] = $buydetail[0]['buildyear1'].'-'.$buydetail[0]['buildyear2'];
$content['remark'] = $buydetail[0]['remark'];
$content['priceunit'] = '万元';
$arr['content'] = serialize($content);
$arr['telno'] = $buydetail[0]['telno'];
$arr['sendid'] = $buydetail[0]['id'];
$arr['sendkind'] = 1;
$arr['tbl'] = 'sell';
$arr['cityname'] = GB_CITY;
$return = $this->addpush($arr);
if($return>0)
{
return 1;
}else{
return 0;
}
}else{
return 0;
}
}
/**
* 查找是否有求购信息加入推送表
* @param type $uid
* @return array
*/
function addrentwanted($uid,$city=GB_CITY,$sendtime)
{
global $house;
$rentwantdetail = $this->user_model->get_rentwant_by_uid($uid,0,1,$sendtime);
if(is_array($rentwantdetail) && !empty($rentwantdetail) && $rentwantdetail[0]['infofrom']!=1){
$arr['uid'] = $uid;
$arr['addtime'] = time();
$arr['level'] = 5;
$content['address'] = $rentwantdetail[0]['address'];
$content['infotype'] = $house['infotype'][$rentwantdetail[0]['infotype']];
$content['buildarea'] = $rentwantdetail[0]['buildarea1'].'-'.$rentwantdetail[0]['buildarea2'];
$content['price'] = $rentwantdetail[0]['price1'].'-'.$rentwantdetail[0]['price2'];
$content['priceunit'] = '元/月';
$content['renttype'] = $house['renttype'][$rentwantdetail[0]['renttype']];
$content['remark'] = $rentwantdetail[0]['remark'];
$arr['content'] = serialize($content);
$arr['telno'] = $rentwantdetail[0]['telno'];
$arr['sendid'] = $rentwantdetail[0]['id'];
$arr['sendkind'] = 1;
$arr['tbl'] = 'rent';
$arr['cityname'] = GB_CITY;
$return = $this->addpush($arr);
if($return>0)
{
return 1;
}else{
return 0;
}
}else{
return 0;
}
}
/**
* 查找是否有求购信息加入推送表
* @param type $uid
* @return array
*/
function addseehouse($uid,$telno,$sendtime)
{
global $house;
$seehousedetail = $this->user_model->get_seehouse_by_telno($telno,$sendtime);
if(!empty($seehousedetail)){
//获取房源信息
$where = array('id'=>$seehousedetail[0]['rowid']);
if($seehousedetail[0]['tbl']=='sell'){
$select = array('id','infotype','uid','infofrom','district','streetid','blockshowname','price','buildarea','floor','subfloor','totalfloor','room','hall','toilet','kitchen','fitment','buildyear');
$housedetail = $this->house_model->gethousebywhere($where,'sell',$select,0,1);
}else{
$select = array('id','infotype','uid','infofrom','district','streetid','blockshowname','price','buildarea','floor','subfloor','totalfloor','room','hall','toilet','kitchen','fitment','renttype','priceunit');
$housedetail = $this->house_model->gethousebywhere($where,'rent',$select,0,1);
}
if(empty($housedetail)) return 0;
//获取街道和经纪人信息
$streetname = $this->block_model->getstreetname($housedetail[0]['streetid']);
$brokername = $this->broker_model->getbrokerdetail($housedetail[0]['uid']);
$arr['uid'] = $uid;
$arr['addtime'] = time();
$arr['level'] = 5;
$content['infotype'] = $house['infotype'][$housedetail[0]['infotype']];
$content['brokername'] = $brokername['truename'];
$content['district'] = $housedetail[0]['district'];
$content['streetname'] = $streetname['streetname'] ;
$content['blockshowname'] = $housedetail[0]['blockshowname'];
$content['buildarea'] = $housedetail[0]['buildarea'];
$content['floor'] = empty($housedetail[0]['subfloor'])?$housedetail[0]['floor'].'/'.$housedetail[0]['totalfloor'].'层':$housedetail[0]['subfloor'].'-'.$housedetail[0]['floor'].'/'.$housedetail[0]['totalfloor'].'层';
$content['room'] = $housedetail[0]['room']?$housedetail[0]['room'].'室':'';
$content['hall'] = $housedetail[0]['hall']?$housedetail[0]['hall'].'厅':'';
$content['toilet'] = $housedetail[0]['room']?$housedetail[0]['room'].'卫':'';
$content['kitchen'] = $housedetail[0]['room']?$housedetail[0]['room'].'厨':'';
$content['fitment'] = $housedetail[0]['fitment'];
if($seehousedetail[0]['tbl']=='sell'){
$content['buildyear'] = $housedetail[0]['buildyear']?$housedetail[0]['buildyear']:'';
$content['price'] = $housedetail[0]['price']?$housedetail[0]['price']:'';
$content['priceunit'] = '万元';
$content['averprice'] = floor($housedetail[0]['price']*10000/$housedetail[0]['buildarea']).'元/平方米';
}else{
$content['price'] = $housedetail[0]['price']?$housedetail[0]['price']:'';
$content['priceunit'] = $house['priceunit'][$housedetail[0]['priceunit']];
$content['renttype'] = $housedetail[0]['renttype'];
}
$arr['content'] = serialize($content);
$arr['telno'] = $telno;
$arr['sendid'] = $seehousedetail[0]['id'];
$arr['sendkind'] = 2;
$arr['tbl'] = $seehousedetail[0]['tbl'];
$arr['cityname'] = GB_CITY;
$return = $this->addpush($arr);
if($return>0)
{
return 1;
}else{
return 0;
}
}else{
return 0;
}
}
/**
* 查找是否有关注信息加入推送表
* @param type $uid
* @return array
*/
function addcollecthouse($uid,$telno,$sendtime)
{
global $house;
$collecthousedetail = $this->user_model->get_collecthouse_by_uid($uid,GB_CITY,$sendtime);
if(!empty($collecthousedetail)){
//获取房源信息
$where = array('id'=>$collecthousedetail['collect_id']);
if($collecthousedetail['kind']=='3'){
$select = array('id','infotype','uid','infofrom','district','streetid','blockshowname','price','buildarea','floor','subfloor','totalfloor','room','hall','toilet','kitchen','fitment','buildyear');
$housedetail = $this->house_model->gethousebywhere($where,'sell',$select,0,1);
}else{
$select = array('id','infotype','uid','infofrom','district','streetid','blockshowname','price','buildarea','floor','subfloor','totalfloor','room','hall','toilet','kitchen','fitment','renttype','priceunit');
$housedetail = $this->house_model->gethousebywhere($where,'rent',$select,0,1);
}
if(empty($housedetail)) return 0;
//获取街道和经纪人信息
$streetname = $this->block_model->getstreetname($housedetail[0]['streetid']);
$brokername = $this->broker_model->getbrokerdetail($housedetail[0]['uid']);
$arr['uid'] = $uid;
$arr['addtime'] = time();
$arr['level'] = 4;
$content['infotype'] = $house['infotype'][$housedetail[0]['infotype']];
$content['brokername'] = $brokername['truename'];
$content['district'] = $housedetail[0]['district'];
$content['streetname'] = $streetname['streetname'] ;
$content['blockshowname'] = $housedetail[0]['blockshowname'];
$content['buildarea'] = $housedetail[0]['buildarea'];
$content['floor'] = empty($housedetail[0]['subfloor'])?$housedetail[0]['floor'].'/'.$housedetail[0]['totalfloor'].'层':$housedetail[0]['subfloor'].'-'.$housedetail[0]['floor'].'/'.$housedetail[0]['totalfloor'].'层';
$content['room'] = $housedetail[0]['room']?$housedetail[0]['room'].'室':'';
$content['hall'] = $housedetail[0]['hall']?$housedetail[0]['hall'].'厅':'';
$content['toilet'] = $housedetail[0]['room']?$housedetail[0]['room'].'卫':'';
$content['kitchen'] = $housedetail[0]['room']?$housedetail[0]['room'].'厨':'';
$content['fitment'] = $housedetail[0]['fitment'];
if($collecthousedetail['kind']=='3'){
$content['buildyear'] = $housedetail[0]['buildyear']?$housedetail[0]['buildyear']:'';
$content['price'] = $housedetail[0]['price']?$housedetail[0]['price']:'';
$content['priceunit'] = '万元';
$content['averprice'] = floor($housedetail[0]['price']*10000/$housedetail[0]['buildarea']).'元/平方米';
}else{
$content['price'] = $housedetail[0]['price']?$housedetail[0]['price']:'';
$content['priceunit'] = $house['priceunit'][$housedetail[0]['priceunit']];
$content['renttype'] = $housedetail[0]['renttype'];
}
$arr['content'] = serialize($content);
$arr['telno'] = $telno;
$arr['sendid'] = $collecthousedetail['id'];
$arr['sendkind'] = 3;
$arr['tbl'] = $collecthousedetail['kind']==3?'sell':'rent';
$arr['cityname'] = GB_CITY;
$return = $this->addpush($arr);
if($return>0)
{
return 1;
}else{
return 0;
}
}else{
return 0;
}
}
/**
* 查找是否有发送到手机加入推送表
* @param type $uid
* @return array
*/
function addsmshouse($uid,$telno,$sendtime)
{
global $house;
if(!$telno) return 0;
$smshousedetail = $this->user_model->get_smshouse_by_telno($telno,0,1,$sendtime);
if(!empty($smshousedetail)){
//获取房源信息
$where = array('id'=>$smshousedetail['rowid']);
if($smshousedetail['tbl']=='sell'){
$select = array('id','infotype','uid','infofrom','district','streetid','blockshowname','price','buildarea','floor','subfloor','totalfloor','room','hall','toilet','kitchen','fitment','buildyear');
$housedetail = $this->house_model->gethousebywhere($where,'sell',$select,0,1);
}else{
$select = array('id','infotype','uid','infofrom','district','streetid','blockshowname','price','buildarea','floor','subfloor','totalfloor','room','hall','toilet','kitchen','fitment','renttype','priceunit');
$housedetail = $this->house_model->gethousebywhere($where,'rent',$select,0,1);
}
if(empty($housedetail)) return 0;
//获取街道和经纪人信息
$streetname = $this->block_model->getstreetname($housedetail[0]['streetid']);
$brokername = $this->broker_model->getbrokerdetail($housedetail[0]['uid']);
$arr['uid'] = $uid;
$arr['addtime'] = time();
$arr['level'] = 4;
$content['infotype'] = $house['infotype'][$housedetail[0]['infotype']];
$content['brokername'] = $brokername['truename'];
$content['district'] = $housedetail[0]['district'];
$content['streetname'] = $streetname['streetname'] ;
$content['blockshowname'] = $housedetail[0]['blockshowname'];
$content['buildarea'] = $housedetail[0]['buildarea'];
$content['floor'] = empty($housedetail[0]['subfloor'])?$housedetail[0]['floor'].'/'.$housedetail[0]['totalfloor'].'层':$housedetail[0]['subfloor'].'-'.$housedetail[0]['floor'].'/'.$housedetail[0]['totalfloor'].'层';
$content['room'] = $housedetail[0]['room']?$housedetail[0]['room'].'室':'';
$content['hall'] = $housedetail[0]['hall']?$housedetail[0]['hall'].'厅':'';
$content['toilet'] = $housedetail[0]['room']?$housedetail[0]['room'].'卫':'';
$content['kitchen'] = $housedetail[0]['room']?$housedetail[0]['room'].'厨':'';
$content['fitment'] = $housedetail[0]['fitment'];
if($smshousedetail['tbl']=='sell'){
$content['buildyear'] = $housedetail[0]['buildyear']?$housedetail[0]['buildyear']:'';
$content['price'] = $housedetail[0]['price']?$housedetail[0]['price']:'';
$content['priceunit'] = '万元';
$content['averprice'] = floor($housedetail[0]['price']*10000/$housedetail[0]['buildarea']).'元/平方米';
}else{
$content['price'] = $housedetail[0]['price']?$housedetail[0]['price']:'';
$content['priceunit'] = $house['priceunit'][$housedetail[0]['priceunit']];
$content['renttype'] = $housedetail[0]['renttype'];
}
$arr['content'] = serialize($content);
$arr['telno'] = $telno;
$arr['sendid'] = $smshousedetail['id'];
$arr['sendkind'] = 4;
$arr['tbl'] = $smshousedetail['tbl'];
$arr['cityname'] = GB_CITY;
$return = $this->addpush($arr);
if($return>0)
{
return 1;
}else{
return 0;
}
}else{
return 0;
}
}
/**
* 查找是否有发送到手机加入推送表
* @param type $uid
* @return array
*/
function addcollectblock($uid,$telno,$sendtime)
{
$collectblockdetail = $this->user_model->getcollectbyuid($uid,2,GB_CITY,$sendtime);
$select=array('blockname','district','streetid','address','averprice');
$blockdetail = $this->block_model->getblockdetail($collectblockdetail['collect_id'],$select);
if(!empty($blockdetail)){
$streetname = $this->block_model->getstreetname($blockdetail['streetid']);
$arr['uid'] = $uid;
$arr['addtime'] = time();
$arr['level'] = 4;
$content['district'] = $blockdetail['district'];
$content['streetname'] = $streetname['streetname'];
$content['blockname'] = $blockdetail['blockname'];
$content['averprice'] = $blockdetail['averprice'];
$content['priceunit'] = '元/平';
$arr['content'] = serialize($content);
$arr['telno'] = $telno;
$arr['sendid'] = $collectblockdetail['id'];
$arr['sendkind'] = 5;
$arr['tbl'] = 'sell';
$arr['cityname'] = GB_CITY;
$return = $this->addpush($arr);
if($return>0)
{
return 1;
}else{
return 0;
}
}else{
return 0;
}
}
/**
* 加入推送表
* @param type $arr
* @return array
*/
function addpush($arr)
{
//设置表
$this->user_model->set_table('push_user');
//过滤表结构
$result = $this->user_model->add($arr,'esf');
return $result;
}
/**
* 加入备选库
* @param type $arr
* @return array
*/
function addalternatives($uid,$telno,$city=GB_CITY,$sendkind=3,$tbl='sell')
{
$arr['uid'] = $uid;
$arr['telno'] = $telno;
$arr['cityname'] = $city;
$arr['sendkind'] = $sendkind;
$arr['tbl'] = $tbl;
$arr['addtime'] = time();
//检查目前不在备选库
$alternatives_id = $this->get_data(array('form_name' => 'alternatives_user','limit'=>1,'where'=>array('telno'=>$telno),'select'=>array('id')),'esf');
if(!empty($alternatives_id[0]['id']))
{
return 0;
}
//设置表
$this->user_model->set_table('alternatives_user');
//过滤表结构
$result = $this->user_model->add($arr,'esf');
return $result;
}
/**
* 验证推送用户是否在白名单或者推送库里
* @param type $uid
* @return array
*/
function yzpush($telno){
if(empty($telno))
{
return 0;
}
//检查白名单
$whitelist_id = $this->get_data(array('form_name' => 'whitelist','limit'=>1,'where'=>array('telno'=>$telno),'select'=>array('id')),'esfbak');
if(!empty($whitelist_id[0]['id']))
{
return $whitelist_id[0]['id'];
}
//检查推送库
$user_id = $this->get_data(array('form_name' => 'push_user','limit'=>1,'where'=>array('telno'=>$telno),'select'=>array('id')),'esf');
if(!empty($user_id[0]['id']))
{
return $user_id[0]['id'];
}
//检查推送库历史库最近一个月记录
$log_id = $this->get_data(array('form_name' => 'push_user_log','limit'=>1,'where'=>array('telno'=>$telno,'sendtime >'=>time()-24*60*60*30),'select'=>array('id')),'esfbak');
if(!empty($log_id[0]['id']))
{
return $log_id[0]['id'];
}else{
return 0;
}
}
//added by bianshiwu 20141222 临时函数
function setPushLogTemp($data){
$sql = "INSERT INTO `push_log_tmp` ( `sendtime` ,`telno` ,`desc`) VALUES ('{$data['sendtime']}','{$data['telno']}','{$data['desc']}')";
$this->db_esf->query($sql);
}
//临时-导数据:wjy
function t_add()
{
$sql = "select * from push_user_log where cityname='nj' and sellnum=0 and id between 36305 and 36371";
$query = $this->db_esf->query($sql)->result_array();
echo count($query);
echo '<br><br>';
foreach($query as $value){
$id = $value['id'];
//step1. 插入push_user
$sql_ins = "INSERT INTO `push_user` (`uid` ,`level` ,`addtime` ,`content` ,`telno` ,`sendid` ,`sendkind` ,`cityname` ,`tbl`) VALUES ('"
.$value['uid']."','".$value['level']."', '".$value['addtime']."', '".$value['content']."', '".$value['telno']."', '".$value['sendid']."', '".$value['sendkind']."', '".$value['cityname']."', '".$value['tbl']."')";
$query = $this->db_esf->query($sql_ins);
$pushid = $this->db_esf->insert_id();
//step2. 删除push_user_log ,marketing_log
if($pushid){
$del_log = $this->db_esf->query("delete from push_user_log where id=$id");
if($del_log){
$del_market = $this->db_esf->query("delete from marketing_log where pushid=$id");
}
}
echo $id; echo '<br>';
echo $pushid; echo '<br>';
var_dump($del_log); echo '<br>';
var_dump($del_market); echo '<br><br>';
die;
}
}
//竞投 手动加数据
function bidhouse()
{
$sql = "select * from growth_bid_house where `type`=2 and `bid_periods_id`=2054 ";
$growth = $this->db_esfhousebak->query($sql)->result_array();
$bid_periods_id = 2059;
$number = 0;
foreach ($growth as $k=>$v){
$str = "('".$v['type']."','".$bid_periods_id."','".$v['block_id']."','".$v['block_level']."','".$v['keyword']."','".$v['broker_level']
. "','".$v['valid']."','" .$number."', '".$v['min_score']."', '".$v['max_win_number']."','".date('Y-m-d H:i:s')."')";
$sql = "INSERT INTO `growth_bid_house` (`type` ,`bid_periods_id` ,`block_id` ,`block_level` ,`keyword` ,`broker_level`,`valid` ,`number` ,`min_score` ,`max_win_number`,`ctime`) VALUES $str";
$query = $this->db_esfhouse->query($sql);
}
}
//新的推送
function getpusharraynew()
{
//---- 日志 ----
$t1 = microtime(true);
writelog('-------- 开始 --------', 'jpushnew_'.date('d') );
$return = array();
//查出推送库
$sql = array('form_name'=>'push_user', 'where'=>array('cityname'=>'nj'), 'order_by'=>'id asc','limit'=>1);
$pushList = $this->get_data($sql, 'esfbak');
if( !empty($pushList) && is_array($pushList) ) {
foreach($pushList as $key=>$val) {
$pushid = 0;
//将信息加入推送历史表,删除推送表
$sql_ins = "INSERT INTO `push_user_log` (`pushuserid` ,`uid` ,`level` ,`sendtime` ,`content` ,`telno` ,`sendid` ,`sendkind` ,`cityname` ,`tbl`,`addtime`) VALUES ('"
.$val['id']."','".$val['uid']."','".$val['level']."','".time()."','".$val['content']."','".$val['telno']."','".$val['sendid']."','".$val['sendkind']."','".$val['cityname']."','".$val['tbl']."','".$val['addtime']."')";
$query = $this->db_esf->query($sql_ins);
$pushid = $this->db_esf->insert_id();
$sql_del = "DELETE from `push_user` where telno='".$val['telno']."'";
$query = $this->db_esf->query($sql_del);
if($val['tbl']=='rent'){
writelog('出租不推:pushid: '.$pushid, 'jpushnew_'.date('d') );
continue;
}
writelog('pushid: '.$pushid, 'jpushnew_'.date('d') );
$arr = $this->getPushDataFromLucene($val); //符合条件经纪人 id
if(empty($arr['uid'])){
$arr_count = count($arr['uid']);
writelog('第一次无数据,再跑一次'.$arr_count, 'jpushnew_'.date('d') );
$arr = $this->getPushDataFromLucene($val, 2); //第一次无数据,再跑一次
}
$arr_count = count($arr['uid']);
if( $arr_count >= 1 && $pushid){
$uidarr = $uarrnew = array();
$i = 0;
foreach($arr['uid'] as $kp => $vp){
$uidarr[] = $kp;
$i++;
$do = $i%500;
if( !$do || $i >= $arr_count ){
$uidstr = implode(',',$uidarr);
$sql = "select b.uid,b.truename,a.agid as agentid,a.agentshortname from broker b
left join agency a on b.agentcode = a.agentcode where b.uid in ($uidstr)";
$query = $this->db_esfhousebak->query($sql);
$userList = $query->result_array();
$str = '';
foreach($userList as $obj) {
if($val['tbl']=='sell') {
$type_tmp ='2';
} else {
$type_tmp ='1';
}
$str .= "('".$pushid."','".$val['uid']."','".$obj['uid']."','".$obj['truename']."','".$obj['agentid']."','".$obj['agentshortname']
."','".time()."','" .$val['telno']."', '".$val['sendid']."', '".$val['sendkind']."','".$type_tmp."'),";
}
if($str) {
$str = rtrim($str,',');
$sql = "INSERT INTO `marketing_log` (`pushid` ,`uid` ,`brokerid` ,`brokername` ,`agentid` ,`agentname`,`addtime` ,`telno` ,`sendid` ,`sendkind`,`tbl`) VALUES $str";
$query = $this->db_esf->query($sql);
}
//转编码
foreach($userList as $tv) {
$tk = $tv['uid'];
$uarrnew[$tk] = $tv;
$uarrnew[$tk]['truename']= mb_convert_encoding($tv['truename'],'utf8','gbk');
$uarrnew[$tk]['agentshortname']= mb_convert_encoding($tv['agentshortname'],'utf8','gbk');
}
$uidarr = array(); //重置一批user
}
}
$return[] = array('content'=>$pushid, 'uarr'=>$uarrnew);
$t3 = microtime(true);
$ttt = round($t3-$t1,1);
writelog('------- 中间耗时 -------- :'.$ttt.'秒' , 'jpushnew_'.date('d') );
}
//极光推送
if(!empty($arr['uid'])){
$this->jpush_uid_data($arr['uid']); //该数组没排除大于5个推送
}
}
}
//---- 日志 ----
$t2 = microtime(true);
$tt = round($t2-$t1,1);
writelog('-------- 结束 --------:耗时'.$tt.'秒' , 'jpushnew_'.date('d') );
return $return;
}
/**
* 获取推送库的信息
* @param type $uid,$remainNum 剩余推送次数
* @return array
*/
function getpusharray($remainNum)
{
if(intval($remainNum) <= 0) return array();
//---- 日志 ----
$t1 = microtime(true);
writelog('-------- 开始 --------', 'jpush_'.date('d') );
//查出推送库总数
$pushCount= $this->get_data(array('form_name' => 'push_user','where'=>array('cityname'=>'nj'),'select'=>array(' count(id) as num')),'esfbak');
$push_num = ceil($pushCount[0]['num']/$remainNum);
$push_num = 1;
//查出推送库
$pushList = $this->get_data(array('form_name' => 'push_user','where'=>array('cityname'=>'nj'), 'order_by'=>'id asc','limit'=>$push_num),'esfbak');
$return = $logdata = $jpush_uid = array();
if( !empty($pushList) && is_array($pushList) ) {
foreach($pushList as $key=>$value) {
$pushid = 0;
//将信息加入推送历史表,删除推送表
$sql_ins = "INSERT INTO `push_user_log` (`pushuserid` ,`uid` ,`level` ,`sendtime` ,`content` ,`telno` ,`sendid` ,`sendkind` ,`cityname` ,`tbl`,`addtime`) VALUES ('"
.$value['id']."','".$value['uid']."','".$value['level']."', '".time()."', '".$value['content']."', '".$value['telno']."', '".$value['sendid']."', '".$value['sendkind']."', '".$value['cityname']."', '".$value['tbl']."', '".$value['addtime']."')";
$query = $this->db_esf->query($sql_ins);
$pushid = $this->db_esf->insert_id();
$sql_del = "DELETE from `push_user` where telno='".$value['telno']."'";
$query = $this->db_esf->query($sql_del);
if($value['tbl']=='rent'){
writelog('出租不推:pushid: '.$pushid, 'jpush_'.date('d') );
continue;
}
writelog('pushid: '.$pushid, 'jpush_'.date('d') );
$arr = $this->getPushDataFromLucene($value); //符合条件经纪人 id
if( count($arr['uid'])>=1 && $pushid){
$uidstr = '';
foreach($arr['uid'] as $kp => $vp){
$uidstr .= $uidstr=='' ? $kp : ','.$kp;
}
//将经纪人加入营销表,判断是否今日已推送5条
$where = " addtime>'".strtotime(date('Y-m-d'))."' and addtime<'".(strtotime(date('Y-m-d'))+86400)."' and brokerid in ($uidstr) ";
$sql = "select count(*) as num, brokerid from marketing_log where $where group by brokerid";
$uarr_num = $this->db_esf->query($sql)->result_array();
$temp_uarr_num = array();
foreach($uarr_num as $op) {
$tp_uid = $op['brokerid'];
$temp_uarr_num[$tp_uid] = $op['num']; //今日经纪人推送条数
}
$sql = "select b.uid,b.truename,a.agid as agentid,a.agentshortname from broker b left join agency a on b.agentcode = a.agentcode where b.valid_flag = 1 and b.uid in ($uidstr)";
$query = $this->db_esfhousebak->query($sql);
$uarr = $query->result_array();
//过滤推送超过5次的经纪人
$str='';
$uarr_filter = array();
if(is_array($uarr) && !empty($uarr)){
foreach($uarr as $value2) {
if(!isset($temp_uarr_num[$value2['uid']]) || $temp_uarr_num[$value2['uid']]<500) {
$uarr_filter[] = $value2['uid'];
if($value['tbl']=='sell') {
$type_tmp ='2';
} else {
$type_tmp ='1';
}
$str .= "('".$pushid."','".$value['uid']."','".$value2['uid']."', '".$value2['truename']."', '".$value2['agentid']."', '".$value2['agentshortname']."', '".time()."', '".$value['telno']."', '".$value['sendid']."', '".$value['sendkind']."', '".$type_tmp."'),";
}
}
}
if($str) {
$str = rtrim($str,',');
$sql = "INSERT INTO `marketing_log` (`pushid` ,`uid` ,`brokerid` ,`brokername` ,`agentid` ,`agentname`,`addtime` ,`telno` ,`sendid` ,`sendkind`,`tbl`) VALUES $str";
$query = $this->db_esf->query($sql);
}
//转编码
$uarrnew = array();
if(is_array($uarr) && !empty($uarr)) {
foreach($uarr as $key=>$value5) {
//过滤符合推送的经纪人
if(in_array($value5['uid'],$uarr_filter)) {
$uarrnew[$key]=$value5;
$uarrnew[$key]['truename']= mb_convert_encoding($value5['truename'],'utf8','gbk');
$uarrnew[$key]['agentshortname']= mb_convert_encoding($value5['agentshortname'],'utf8','gbk');
}
}
}
$contentnew = '';
$re['content'] = $contentnew;
$re['uarr'] = $uarrnew;
$return[] = $re;
$t3 = microtime(true);
$ttt = round($t3-$t1,1);
writelog('中间耗时:'.$ttt.'秒' , 'jpush_'.date('d') );
if(!empty($uarr_filter)){
$j_arr = array_flip($uarr_filter);
$this->jpush_uid_data($j_arr); //该数组 过滤 大于5个推送
//$this->jpush_uid_data($arr['uid']); //该数组没排除大于5个推送
}
}
}
}
//---- 日志 ----
$t2 = microtime(true);
$tt = round($t2-$t1,1);
writelog('-------- 结束 --------:耗时'.$tt.'秒' , 'jpush_'.date('d') );
return $return;
}
/**
* 分站获取推送库的信息
* @param type $uid,$remainNum 剩余推送次数
* @return array
*/
function getpusharraycity($remainNum,$city)
{
if(intval($remainNum) <= 0) return array();
//查出推送库总数
$push_array_num = $this->get_data(array('form_name' => 'push_user','where'=>array('cityname'=>$city),'select'=>array(' count(id) as num')),'esfbak');
$push_num = ceil($push_array_num[0]['num']/$remainNum);
$push_num = 20;
//查出推送库
$push_array = $this->get_data(array('form_name' => 'push_user','where'=>array('cityname'=>$city), 'order_by'=>'id asc','limit'=>$push_num),'esfbak');
//print_r($push_array);die;
if(is_array($push_array) && !empty($push_array))
{
foreach($push_array as $key=>$value)
{
$pushid = 0;
// if($key <4) continue;
//将信息加入推送历史表,删除推送表
$sql = "INSERT INTO `push_user_log` (`pushuserid` ,`uid` ,`level` ,`sendtime` ,`content` ,`telno` ,`sendid` ,`sendkind` ,`cityname` ,`tbl`,`addtime`) VALUES ('".$value['id']."','".$value['uid']."','".$value['level']."', '".time()."', '".$value['content']."', '".$value['telno']."', '".$value['sendid']."', '".$value['sendkind']."', '".$value['cityname']."', '".$value['tbl']."', '".$value['addtime']."')";
//$query = $this->db_esf->query($sql);
//$pushid = $this->db_esf->insert_id();//自增id
$sql2 = "DELETE from `push_user` where telno='".$value['telno']."'";
//$query = $this->db_esf->query($sql2);
//对信息进行处理(第一次如果查询异常,再查询一次)
$arr = $this->get_luc_data($value);
if(count($arr['uid']) > 1)
{
$uidstr = '';
foreach($arr['uid'] as $key4=>$value4)
{
$uidstr .= $uidstr == '' ? $key4 : ','.$key4;
}
//记录日志
$msg = "************************************************ \n";
$msg .= date('Y-m-d H:i:s').var_export($arr['uid'],true)." \n";
$log = dirname(__FILE__)."/getpusharray.log";
file_put_contents($log,$msg,FILE_APPEND );
//将经纪人加入营销表,判断是否今日已推送5条
$sql = "select count(*) as num,brokerid from marketing_log where addtime>'".strtotime(date('Y-m-d'))."' and addtime<'".(strtotime(date('Y-m-d'))+24*60*60)."' and brokerid in ($uidstr) group by brokerid";
$query = $this->db_esf->query($sql);
$uarr_num = $query->result_array();
$temp_uarr_num = array();
if(is_array($uarr_num) && !empty($uarr_num))
{
foreach($uarr_num as $value1)
{
//今日经纪人推送条数
$temp_uarr_num[$value1['brokerid']]=$value1['num'];
}
}
$sql = "select b.uid,b.truename,a.agid as agentid,a.agentshortname from broker b left join agency a on b.agentcode = a.agentcode where b.valid_flag = 1 and b.uid in ($uidstr)";
$query = $this->db_esfhousebak->query($sql);
$uarr = $query->result_array();
//过滤推送超过5次的经纪人
$str='';
$uarr_filter = array();
if(is_array($uarr) && !empty($uarr)){
foreach($uarr as $value2)
{
if(!isset($temp_uarr_num[$value2['uid']]) || $temp_uarr_num[$value2['uid']]<5)
{
$uarr_filter[] = $value2['uid'];
$str .= "('".$pushid."','".$value['id']."','".$value2['uid']."', '".$value2['truename']."', '".$value2['agentid']."', '".$value2['agentshortname']."', '".time()."', '".$value['telno']."', '".$value['sendid']."', '".$value['sendkind']."'),";
}
}
}
if($str)
{
$str = rtrim($str,',');
$sql = "INSERT INTO `marketing_log` (`pushid` ,`uid` ,`brokerid` ,`brokername` ,`agentid` ,`agentname`,`addtime` ,`telno` ,`sendid` ,`sendkind`) VALUES $str";
$query = $this->db_esf->query($sql);
}
//转编码
$uarrnew = array();
if(is_array($uarr) && !empty($uarr))
{
foreach($uarr as $key=>$value5)
{
//过滤符合推送的经纪人
if(in_array($value5['uid'],$uarr_filter))
{
$uarrnew[$key]=$value5;
$uarrnew[$key]['truename']= mb_convert_encoding($value5['truename'],'utf8','gbk');
$uarrnew[$key]['agentshortname']= mb_convert_encoding($value5['agentshortname'],'utf8','gbk');
}
}
}
$re['content'] = $contentnew;
$re['uarr'] = $uarrnew;
$return[] = $re;
//print_r($return);die;
$this->jpush_uid_data($arr['uid']);
}
}
return $return;
}
}
function get_luc_data($value)
{
$content = unserialize($value['content']);
$address =explode("-",$content['address']);
$street =$address['1'];
$street ="大房郢水库";
$sql_street = "select id from street where streetname='$street' limit 1";
$query_street = $this->db_esfhousebak->query($sql_street);
$street_arr = $query_street->result_array();
$street_id =$street_arr[0]['id'];
//echo $street_id;die;
$price =explode("-",$content['price']);
$price1 =$price['0'];
$price2 =$price['1'];
/*
print_r($content);die;
$sql = "select uid from sell where esta=1 and street_id='$street_id'";
$query = $this->db_esfhousebak->query($sql);
$uarr = $query->result_array();
$sql_search ="select id from sell where esta=1 luc";
*/
error_reporting(E_ALL);
ini_set('display_errors', '1');
$arr['strCheckMethod'] ="";
$arr['returnMethod'] ="ary";
$arr['returnCharSet'] ="gbk";
if($value['tbl']=='sell')
{
//print_r($value['content']);
$content = unserialize($value['content']);
$arr['appName'] =NS_SELL;
$sql_condition ="";
$server = new Server($arr,"","ary","gbk");
$sql_search ="select id from sell where esta=1 luc";
$ary = $server->query($sql_search);
print_r($ary);die;
}
else
{
$arr['appName'] =NS_RENT;
$sql_condition ="";
}
}
/**
* 获取推送库的信息
* @param type $uid,$remainNum 剩余推送次数
* @return array
*/
function getpusharraytest($remainNum){
if(intval($remainNum) <= 0) return array();
//查出推送库总数
$push_array_num = $this->get_data(array('form_name' => 'push_user','where'=>array('cityname'=>'nj'),'select'=>array(' count(id) as num')),'esfbak');
$push_num = ceil($push_array_num[0]['num']/$remainNum);
$push_num = 20;
//查出推送库
$push_array = $this->get_data(array('form_name' => 'push_user','where'=>array('cityname'=>'nj','telno'=>'18655070104'), 'order_by'=>'id asc','limit'=>$push_num),'esfbak');
//'where_in'=>array('telno',array(13813048550,15150897128,13062566161,18652058969,18260048358)),
//print_r($push_array);die;
if(is_array($push_array) && !empty($push_array)){
foreach($push_array as $key=>$value){
$pushid = 0;
// if($key <4) continue;
//将信息加入推送历史表,删除推送表
$sql = "INSERT INTO `push_user_log` (`pushuserid` ,`uid` ,`level` ,`sendtime` ,`content` ,`telno` ,`sendid` ,`sendkind` ,`cityname` ,`tbl`) VALUES ('".$value['id']."','".$value['uid']."','".$value['level']."', '".time()."', '".$value['content']."', '".$value['telno']."', '".$value['sendid']."', '".$value['sendkind']."', '".$value['cityname']."', '".$value['tbl']."')";
$query = $this->db_esf->query($sql);
$pushid = $this->db_esf->insert_id();//自增id
$sql2 = "DELETE from `push_user` where telno='".$value['telno']."'";
$query = $this->db_esf->query($sql2);
//对信息进行处理(第一次如果查询异常,再查询一次)
//$arr = $this->get_solr_data($value);
$arr['uid']['850507']=1;
$arr['uid']['835248']=1;
if(isset($arr['blockid'])){
$arr =array();
$arr = $this->get_solr_data($value);
}
//$arr['uid']=array('835248'=>'1','822557'=>'2','857996'=>'2','857992'=>'2','850507'=>'2','827694'=>'2','827350'=>'1');
//$arr['uid']=array('850507'=>'1','860097'=>'2','860103'=>'2','860101'=>'2','860099'=>'2','827350'=>'1','859958'=>1,'857568'=>1);
//print_r($arr['uid']);die;
$this->jpush_uid_data($arr['uid']);
if(count($arr['uid']) >= 1){
$uidstr = '';
foreach($arr['uid'] as $key4=>$value4)
{
$uidstr .= $uidstr == '' ? $key4 : ','.$key4;
}
//将经纪人加入营销表,判断是否今日已推送5条
$sql = "select count(*) as num,brokerid from marketing_log where addtime>'".strtotime(date('Y-m-d'))."' and addtime<'".(strtotime(date('Y-m-d'))+24*60*60)."' and brokerid in ($uidstr) group by brokerid";
//echo $sql;die;
$query = $this->db_esf->query($sql);
$uarr_num = $query->result_array();
$temp_uarr_num = array();
if(is_array($uarr_num) && !empty($uarr_num)){
foreach($uarr_num as $value1)
{
//今日经纪人推送条数
$temp_uarr_num[$value1['brokerid']]=$value1['num'];
}
}
$sql = "select b.uid,b.truename,a.agid as agentid,a.agentshortname from broker b left join agency a on b.agentcode = a.agentcode where b.valid_flag = 1 and b.uid in ($uidstr)";
$query = $this->db_esfhousebak->query($sql);
$uarr = $query->result_array();
//过滤推送超过5次的经纪人
$str='';
$uarr_filter = array();
if(is_array($uarr) && !empty($uarr)){
foreach($uarr as $value2)
{
if(!isset($temp_uarr_num[$value2['uid']]) || $temp_uarr_num[$value2['uid']]<5)
{
$uarr_filter[] = $value2['uid'];
$str .= "('".$pushid."','".$value['id']."','".$value2['uid']."', '".$value2['truename']."', '".$value2['agentid']."', '".$value2['agentshortname']."', '".time()."', '".$value['telno']."', '".$value['sendid']."', '".$value['sendkind']."'),";
}
}
}
if($str){
$str = rtrim($str,',');
$sql = "INSERT INTO `marketing_log` (`pushid` ,`uid` ,`brokerid` ,`brokername` ,`agentid` ,`agentname`,`addtime` ,`telno` ,`sendid` ,`sendkind`) VALUES $str";
$query = $this->db_esf->query($sql);
}
//转编码
$uarrnew = array();
if(is_array($uarr) && !empty($uarr)){
foreach($uarr as $key=>$value5){
//过滤符合推送的经纪人
if(in_array($value5['uid'],$uarr_filter)){
$uarrnew[$key]=$value5;
$uarrnew[$key]['truename']= mb_convert_encoding($value5['truename'],'utf8','gbk');
$uarrnew[$key]['agentshortname']= mb_convert_encoding($value5['agentshortname'],'utf8','gbk');
}
}
}
$re['content'] = $contentnew;
$re['uarr'] = $uarrnew;
$return[] = $re;
//print_r($return);die;
}
}
//print_r($return);die;
return $return;
}
}
//按照别名 批量推送 :wjy 2019-06-18 超时不用
function jpush_uid_data_all($idsOrg)
{
$uidarr = array();
foreach($idsOrg as $key=>$val) {
if($key){
$uidarr[] = $key;
}
}
$uidstr = implode(',', $uidarr);
if(empty($uidstr)){
return true;
}
$sql = "select alias,devicetype from user_token where uid in ($uidstr)";
$query = $this->db_esfhousebak->query($sql)->result_array();
$android_list = $ios_list = $find = array();
foreach ($query as $vp){
$alias = $vp['alias'];
$device = $vp['devicetype'];
if($device && $alias && !in_array($alias, $find)) {
$find[] = $alias;
if($device=='android'){
$android_list[] = $alias;
}else{
$ios_list[] = $alias;
}
}
}
//极光推送
require_once(dirname(__FILE__)."/jpush/JPush.php");
require_once(dirname(__FILE__)."/jpush/JPushException.php");
$str = "您有新的客户可抢,手慢无!快去查看→";
$content = $title = $msg = mb_convert_encoding($str, 'utf-8', 'gbk');
$extras = array('type'=>1,'content'=>$content,'url'=>'');
$uri = array("uri"=>$extras);
$app_key = "642b9e71e51654b5aec60a04";
$master_secret = "a3e177784496e726cbb12e3e";
$logFile = './log/'.date('Ym').'/jpushlog_'.date('d').'.log';
$maxTime = 10;
//初始化
$client = new JPush($app_key, $master_secret, $logFile, $maxTime);
if($android_list){
try{
$result = $client->push()
->setPlatform(array('android'))
->addAlias($android_list)
->setMessage($msg, $title, '', $uri)
->setOptions(null, null, null, false)
->send();
}catch (APIRequestException $e){
$_push_result = $e->getMessage();
writelog('android__: '.print_r($_push_result,1), 'jpush_'.date('d') );
}
}
if($ios_list){
try{
$result = $client->push()
->setPlatform(array('ios'))
->setNotificationAlert($title)
->addAlias($ios_list)
->addAndroidNotification($msg, $title, null, $uri)
->addIosNotification($msg, null, '+1', null, null, $uri)
->setOptions(null, null, null, true)
->send();
}catch (Exception $e){
$_push_result = $e->getMessage();
writelog('ios__: '.print_r($_push_result,1), 'jpush_'.date('d') );
}
}
return true;
}
function jpush_uid_data($value)
{
$str ="";
foreach ($value as $key =>$rs) {
$str .=$key.',';
}
$uidstr =trim($str,',');
$sql = "select alias from user_token where uid in ($uidstr)";
$query = $this->db_esfhousebak->query($sql);
$uarr = $query->result_array();
$alias = array();
foreach ($uarr as $key =>$data) {
if($data['alias']) {
$alias[] =$data['alias'];
}
}
if( empty($alias) ){
return true;
}
require_once(dirname(__FILE__)."/jpush/JPush.php");
$str = "您有新的客户可抢,手慢无!快去查看→";
$content = $title = $msg = mb_convert_encoding($str, 'utf-8', 'gbk');
$extras = array('type'=>1,'content'=>$content,'url'=>'');
$uri = array("uri"=>$extras);
$app_key = "642b9e71e51654b5aec60a04";
$master_secret = "a3e177784496e726cbb12e3e";
$logFile = './log/'.date('Ym').'/jpushlog_'.date('d').'.log';
$maxTime = 5;
// 初始化
$client = new JPush($app_key, $master_secret, $logFile, $maxTime);
foreach ($alias as $key =>$rs)
{
$sql = "select devicetype from user_token where alias = '$rs'";
$aliasTest = array($rs);
$query = $this->db_esfhousebak->query($sql);
$devicetypedata = $query->result_array();
$devicetype =$devicetypedata['0']['devicetype'];
if($devicetype=='android')
{
$result = $client->push()
->setPlatform(array('android'))
//->setNotificationAlert($title)
->addAlias($aliasTest)
//->addAndroidNotification($msg, $title, null, $uri)
//->addIosNotification($msg, null, '+1', null, null, $uri)
->setMessage($msg, $title, '', $uri)
->setOptions(null, null, null, false)
->send();
}
else
{
$result = $client->push()
->setPlatform(array('ios'))
->setNotificationAlert($title)
->addAlias($aliasTest)
->addAndroidNotification($msg, $title, null, $uri)
->addIosNotification($msg, null, '+1', null, null, $uri)
//->setMessage('msg', 'title', '', array('type'=>2,'taskId'=>467,'signtype'=>1,'signId'=>1613))
->setOptions(null, null, null, true)
->send();
}
}
}
/**
* 再次通过solr获得数据
* @param type $array
* @return array
*/
function get_solr_data($value){
global $solr_conf_arr,$house;
$city = 'nj';
if($value['tbl']=='sell'){
$this->load->library('solr_class',array('api_url'=>$solr_conf_arr[$city][$value['tbl']]),'solr_sell');
$this->solr_class =$this->solr_sell;
}else{
$this->load->library('solr_class',array('api_url'=>$solr_conf_arr[$city][$value['tbl']]),'solr_rent');
$this->solr_class =$this->solr_rent;
}
$content = unserialize($value['content']);
$infotype_flip = array_flip($house['infotype']);
if($value['sendkind']==1){
$address = explode('/',$content['address']);
$streetname1 = substr(strstr($address[0],'-'),1);
$streetname2 = substr(strstr($address[1],'-'),1);
$streetname3 = substr(strstr($address[2],'-'),1);
$streetid1 = $this->block_model->getstreetdetailbyname($streetname1,array('id'));
$streetid2 = $this->block_model->getstreetdetailbyname($streetname2,array('id'));
$streetid3 = $this->block_model->getstreetdetailbyname($streetname3,array('id'));
$infotype = $infotype_flip[$content['infotype']];
//$buildarea = explode('-',$content['buildarea']);
//$buildarea1 = $buildarea[0];
//$buildarea2 = $buildarea[1];
$price = explode('-',$content['price']);
$price1 = $price[0];
$price2 = $price[1];
$buildyear = explode('-',$content['buildyear']);
$buildyear1 = $buildyear[0];
$buildyear2 = $buildyear[1];
if(!empty($content['renttype'])){
$renttype = $content['renttype'];
}
}elseif($value['sendkind']==2 or $value['sendkind']==3 or $value['sendkind']==4){
$infotype = $infotype_flip[$content['infotype']];
$blockname = $content['blockshowname'];
if($value['tbl']=='rent'){
if($content['price']<=800){
$price1 = 0;
$price2 = 1500;
}elseif($content['price']>800 && $content['price']<=1200){
$price1 = 500;
$price2 = 2000;
}elseif($content['price']>1200 && $content['price']<=2000){
$price1 = 800;
$price2 = 2500;
}elseif($content['price']>2000 && $content['price']<=3000){
$price1 = 1500;
$price2 = 3500;
}elseif($content['price']>3000 && $content['price']<=5000){
$price1 = 2000;
$price2 = 6000;
}elseif($content['price']>5000 && $content['price']<=10000){
$price1 = 4000;
$price2 = 11000;
}elseif($content['price']>=10000){
$price1 = 10000;
$price2 = 999999;
}
}else{
if($content['price']<=40){
$price1 = 0;
$price2 = 60;
}elseif($content['price']>40 && $content['price']<=60){
$price1 = 30;
$price2 = 80;
}elseif($content['price']>60 && $content['price']<=90){
$price1 = 50;
$price2 = 120;
}elseif($content['price']>90 && $content['price']<=120){
$price1 = 80;
$price2 = 150;
}elseif($content['price']>120 && $content['price']<=150){
$price1 = 100;
$price2 = 180;
}elseif($content['price']>150 && $content['price']<=200){
$price1 = 120;
$price2 = 220;
}elseif($content['price']>200 && $content['price']<=300){
$price1 = 150;
$price2 = 350;
}elseif($content['price']>300 && $content['price']<=500){
$price1 = 250;
$price2 = 600;
}elseif($content['price']>=500){
$price1 = 500;
$price2 = 999999;
}
}
}elseif($value['sendkind']==5){
$blockname = $content['blockname'];
}
if($blockname != '')
{
$this->solr_class->setQueryField(array("blockshowname"=>$blockname));
}
else
{
$this->solr_class->setQueryField("");
}
$streetarr = $ffarr = array();
$ffarr[] = array("oper"=>"NOT", "field"=>"uid", "inneroper"=>":", "value"=>0);
$ffarr[] = array("oper"=>"AND", "field"=>"esta", "inneroper"=>":", "value"=>1);
$ffarr[] = array("oper"=>"AND", "field"=>"infofrom", "inneroper"=>":", "value"=>5);
if(isset($streetid1) && $streetid1 > 0)
{
$streetarr[] = $streetid1['id'];
}
if(isset($streetid2) && $streetid2 > 0)
{
$streetarr[] = $streetid2['id'];
}
if(isset($streetid3) && $streetid3 > 0)
{
$streetarr[] = $streetid3['id'];
}
if($streetarr)
{
$ffarr[] = array("oper"=>"AND", "field"=>"streetid", "inneroper"=>"OR", "value"=>$streetarr);
}
if($infotype > 0)
{
$ffarr[] = array("oper"=>"AND", "field"=>"infotype", "inneroper"=>":", "value"=>$infotype);
}
if($buildarea1 > 0 || $buildarea2 > 0)
{
if($buildarea1 < $buildarea2)
{
$ffarr[] = array("oper"=>"AND", "field"=>"buildarea", "inneroper"=>"TO", "value"=>array($buildarea1,$buildarea2));
}
else
{
$ffarr[] = array("oper"=>"AND", "field"=>"buildarea", "inneroper"=>":", "value"=>$buildarea1);
}
}
if($buildyear1 > 0 && $buildyear2 > 0)
{
if($buildyear1 < $buildyear2)
{
$ffarr[] = array("oper"=>"AND", "field"=>"buildyear", "inneroper"=>"TO", "value"=>array($buildyear1,$buildyear2));
}
else
{
$ffarr[] = array("oper"=>"AND", "field"=>"buildyear", "inneroper"=>":", "value"=>$buildyear1);
}
}
if($price1 > 0 || $price2 > 0)
{
if($price1 < $price2)
{
$ffarr[] = array("oper"=>"AND", "field"=>"price", "inneroper"=>"TO", "value"=>array($price1,$price2));
}
else
{
$ffarr[] = array("oper"=>"AND", "field"=>"price", "inneroper"=>":", "value"=>$price1);
}
}
if($renttype != '' && $value['tbl'] == 'rent')
{
$ffarr[] = array("oper"=>"AND", "field"=>"renttype", "inneroper"=>":", "value"=>$renttype);
}
if($ffarr)
{
$this->solr_class->setFilterField($ffarr);
}
//print_r($ffarr);
$this->solr_class->setCountNum(100);
$this->solr_class->setCountField(array("uid"));
$arr = $this->solr_class->query('countgroup');
//print_r($arr);die;
return $arr;
}
/**
* 获取向经纪人推送的信息
* @param type $brokerid
* @return array
*/
function Getpushnumbybrokerid($brokerid,$ctime,$is_buy,$page=1,$pagesize=20){
if($is_buy==1){
//$sql = "select b.content,a.addtime,a.is_buy,a.is_sendtelno,a.brokerid,b.sendid,b.sendkind,b.id as pushid,b.telno,b.tbl,b.level,b.sellnum,a.cusIntention from push_user_log b left join marketing_log a on b.telno = a.telno where a.addtime>'".$ctime."' and a.brokerid='".$brokerid."' and a.is_buy='".$is_buy."' order by b.id desc limit ".($page-1)*$pagesize.",".$pagesize."" ;
$sql = "select b.content,a.addtime,a.is_buy,a.is_sendtelno,a.brokerid,b.sendid,b.sendkind,b.id as pushid,b.telno,b.tbl,b.level,b.sellnum,a.cusIntention from push_user_log b left join marketing_log a on b.id = a.pushid where a.addtime>'".$ctime."' and a.brokerid='".$brokerid."' and a.is_buy='".$is_buy."' order by b.id desc limit ".($page-1)*$pagesize.",".$pagesize."" ;
}else{
//$sql = "select b.content,a.addtime,a.is_buy,a.is_sendtelno,a.brokerid,b.sendid,b.sendkind,b.id as pushid,b.telno,b.tbl,b.level,b.sellnum,a.cusIntention from push_user_log b left join marketing_log a on b.telno = a.telno where a.addtime>'".$ctime."' and a.brokerid='".$brokerid."' order by b.id desc " ;
$sql = "select b.content,a.addtime,a.is_buy,a.is_sendtelno,a.brokerid,b.sendid,b.sendkind,b.id as pushid,b.telno,b.tbl,b.level,b.sellnum,a.cusIntention from push_user_log b left join marketing_log a on b.id = a.pushid where a.addtime>'".$ctime."' and a.brokerid='".$brokerid."' order by b.id desc " ;
}
$query = $this->db_esfbak->query($sql);
$arr = $query->result_array();
if($arr){
foreach($arr as $key=>$value)
{
$arr1[$key] = $value;
$con = unserialize($value['content']);
//wjy:处理 字符类型问题
if($con===false){
$unserialized = preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $value['content'] );
$con = unserialize($unserialized);
}
if($con){
foreach($con as $key1=> $value1){
if($key1=='buildyear'){
$arr2[$key1]= mb_convert_encoding($value1.'年','utf8','gbk');
}elseif($key1=='buildarea'){
$arr2[$key1]= mb_convert_encoding($value1.'平米','utf8','gbk');
}elseif($key1=='brokername'){
}else{
$arr2[$key1]= mb_convert_encoding($value1,'utf8','gbk');
}
}
}
$arr1[$key]['content']=$arr2;
}
}
return $arr1;
}
/**
* 获取向经纪人推送的信息的数量
* @param type $brokerid
* @return array
*/
function Getpushnumbybroker($brokerid,$ctime,$is_buy){
if($is_buy==1){
//$sql = "select count(a.id) as num from push_user_log b left join marketing_log a on b.telno = a.telno where a.addtime>'".$ctime."' and a.brokerid='".$brokerid."' and a.is_buy='".$is_buy."'";
$sql = "select count(a.id) as num from push_user_log b left join marketing_log a on b.id = a.pushid where a.addtime>'".$ctime."' and a.brokerid='".$brokerid."' and a.is_buy='".$is_buy."'";
}else{
//$sql = "select count(a.id) as num from push_user_log b left join marketing_log a on b.telno = a.telno where a.addtime>'".$ctime."' and a.brokerid='".$brokerid."'" ;
$sql = "select count(a.id) as num from push_user_log b left join marketing_log a on b.id = a.pushid where a.addtime>'".$ctime."' and a.brokerid='".$brokerid."'" ;
}
$query = $this->db_esfbak->query($sql);
$arr = $query->result_array();
return $arr[0];
}
/**
* 获取推送信息的出售次数和推送的经纪人
* @param type $brokerid
* @return array
*/
function Getsellnumbypush($telno,$sendid,$sendkind){
$key = $this->memkey.'_Getsellnumbypush'.$telno.$sendid.$sendkind;
if($this->input->get('update') == 1)
{
$this->memcached_class->delete($key);
}
$pushdetail = $this->memcached_class->get($key);
if( empty($pushdetail) )
{
$pushdetail= $this->get_data(array('form_name' => 'push_user_log','limit'=>1,'where'=>array('telno'=>$telno,'sendid'=>$sendid,'sendkind'=>$sendkind,'sendtime >'=>time()-24*60*60*30),'select'=>array('sellnum','broker','sendid','sendkind')),'esfbak');
$this->memcached_class->add($key, $pushdetail,3600);
}
return $pushdetail[0];
}
/**
* 获取推送信息详细信息
* @param type $pushid
* @return array
*/
function Getpushdetal($pushid){
$key = $this->memkey.'Getpushdetal'.$pushid;
$this->memcached_class->delete($key);
if($this->input->get('update') == 1){
$this->memcached_class->delete($key);
}
$pushdetail = $this->memcached_class->get($key);
if( empty($pushdetail) ){
$pushdetail= $this->get_data(array('form_name' => 'push_user_log','limit'=>1,'where'=>array('id'=>$pushid),'select'=>array('sellnum','broker','sendid','sendkind','telno')),'esf');
$this->memcached_class->add($key, $pushdetail,86400);
}
return $pushdetail[0];
}
/**
* 更新推送信息的出售次数
* @param type $brokerid,$type 1,更新是否电话,2更新是否购买
* @return array
*/
function Updatebrokerpush($brokerid,$type,$pushid){
//检查是否可购买次数已满,或者此经纪人已经购买过
$push_log = $this->Getpushdetal($pushid);
if($type==1){
$arr = array('brokerid' => $brokerid,'pushid'=>$pushid);
$up=array('is_sendtelno'=>1,'sendtelnotime'=>time());
$this->set_table('marketing_log');
$result = $this->save($arr,$up,'esf');
return 1;
}else{
if($push_log['sellnum'] >= 3)
{
return 'N_FULL';
}elseif(strpos($push_log['broker'],$brokerid)){
return 'N_BUY';
}
$arr = array('brokerid' => $brokerid,'pushid'=>$pushid);
$up=array('is_buy'=>1,'buytime'=>time());
$this->set_table('marketing_log');
$result = $this->save($arr,$up,'esf');
//更新推送历史表
if($result>0)
{
//删除缓存
$this->memcached_class->delete($this->memkey.'Getpushdetal'.$pushid);
$up=array('sellnum'=>($push_log['sellnum']+1),'broker'=>$push_log['broker'].'&'.$brokerid);
$arr=array('id'=>$pushid);
$this->set_table('push_user_log');
$result = $this->save($arr,$up,'esf');
}
$telno = $push_log['telno'];
$sql = "select middle_phone from middlephone_relation where call_phone='".$telno."' and `status`=1 and type=4 ";
$query = $this->db_esfhousebak->query($sql);
$middle = $query->result_array();
if($middle){
$telno = $middle[0]['middle_phone'];
}
return array('telno'=>$telno);
}
}
/**
* 删除备选库的内容
* @param type $telno,电话
* @return array
*/
function delalternatives($telno)
{
//删除备选库
$this->push_model->set_table('alternatives_user');
$result = $this->push_model->del_mul($telno,'telno','esf');
}
/**
* 通过手机获取推送历史库库的信息
* @param string $telno
* @return array
*/
function getpushlogbytelno($telno){
/*
$key = $this->memkey.'getpushlogbytelno'.$telno;
if($this->input->get('update') == 1)
{
$this->memcached_class->delete($key);
}
$pushdetail = $this->memcached_class->get($key);
*/
$pushdetail = false;
if( empty($pushdetail) ){
$pushdetail = $this->get_data(array('form_name' => 'push_user_log','where'=>array('telno'=>$telno),'select'=>array('sendtime'),'order_by'=>'sendtime desc','limit'=>1),'esf');
//$this->memcached_class->add($key, $pushdetail,3600);
}
return isset($pushdetail[0]['sendtime'])?$pushdetail[0]['sendtime']:'';
}
//测试中间件返回数据
function test_push()
{
$arr = array();
$arr['strCheckMethod'] = "";
$arr['returnMethod'] = "ary";
$arr['returnCharSet'] = "gbk";
$arr['appName'] = NS_SELL; // sell表标记 $tbl = 'sell';
$server = new Server($arr,"","ary","gbk");
$sql = "select * from sell where esta=1 and infofrom=5 and district ='浦口区' group by uid limit 0, 10000 luc";
$ary = $server->query($sql);
var_dump($ary);
}
function getPushDataFromLucene($value, $tag=0)
{
$content = unserialize($value['content']);
if($tag==2){
writelog('第二次:'.print_r($value, 1), 'jpushnew_'.date('d') );
}
//wjy:处理 字符类型问题
if($content===false){
$unserialized = preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $value['content'] );
$content = unserialize($unserialized);
}
$address = explode("-",$content['address']);
$street = $address['1'];
if(strpos($street, '/')) {
$street_arr = explode("/",$street);
$street = $street_arr['0'];
}
$district = $address['0'];
$sql_street = "select id from street where streetname='$street' and district='$district' limit 1";
$query_street = $this->db_esfhousebak->query($sql_street);
$street_arr = $query_street->result_array();
$street_id = $street_arr[0]['id'];
$price = explode("-",$content['price']);
$price1 = $price['0']*0.8;
$price2 = $price['1']*1.2;
// if( empty($street_id) ){
// writelog('getPushDataFromLucene空的街道id:'.print_r($value, 1), 'jpush_'.date('d') );
// return true;
// }
if( empty($district) ){
writelog('getPushDataFromLucene空的区属:'.print_r($value, 1), 'jpushnew_'.date('d') );
return true;
}
$arr = array();
$arr['strCheckMethod'] = "";
$arr['returnMethod'] = "ary";
$arr['returnCharSet'] = "gbk";
if($value['tbl']=='sell') {
$arr['appName'] = NS_SELL;
$tbl = 'sell';
} else {
$arr['appName'] = NS_RENT;
$tbl = 'rent';
}
$infotype = $content['infotype'];
$sql_condition1 = " ";
// if($infotype=='住宅') {
// $sql_condition1 = "infotype=1 and";
// }elseif($infotype=='别墅') {
// $sql_condition1 = "infotype=2 and";
// }elseif($infotype=='写字楼') {
// $sql_condition1 = "infotype=3 and";
// }elseif($infotype=='商铺') {
// $sql_condition1 = "infotype=4 and";
// }elseif($infotype=='车库车位') {
// $sql_condition1 = "infotype=6 and";
// }elseif($infotype=='厂房仓库') {
// $sql_condition1 = "infotype=5 and";
// }
if($value['tbl']=='sell')
{
$server= new Server($arr,"","ary","gbk");
//$where = $sql_condition1." esta=1 and infofrom=5 and streetid ='$street_id' group by uid limit 0, 10000"; //district
$where = $sql_condition1." esta=1 and infofrom=5 and district ='".$district."' group by uid limit 0, 10000";
$sql = "select * from ".$tbl." where $where luc";
writelog('fromLucene:'.$sql, 'jpushnew_'.date('d') );
$ary = $server->query($sql);
$values = array();
if(count($ary['GroupRecord'])) {
if(empty($ary['GroupRecord'][0])) {
$ary['GroupRecord'] =array($ary['GroupRecord']);
}
foreach ($ary['GroupRecord'] as $key => $rs) {
$values['uid'][$rs['Group']] = $rs['Count'];
}
}
} else {
//出租 rent
$where = $sql_condition1." esta=1 and infofrom=5 and streetid ='$street_id' group by uid limit 0,200";
$sql = "select uid from ".$tbl." FORCE INDEX(infofrom_esta_infotype) where $where ";
$query = $this->db_esfhousebak->query($sql);
$result = $query->result_array();
$values = array();
foreach ($result as $vp) {
$values['uid'][$vp['uid']] = '1';
}
}
if(!empty($values)){
$tparr = array();
foreach($values['uid'] as $key => $val){
$tparr[] = $key;
}
$string = implode(',', $tparr);
// 按照登录时间排序
// $sql = sprintf('SELECT uid FROM broker WHERE uid IN(%s) ORDER BY logintime DESC limit 1000', $string);
// $loginList = $this->db_esfhousebak->query($sql)->result_array();
// $array = array();
// if($loginList){
// foreach($loginList as $op){
// $uid = $op['uid'];
// if(isset($values['uid'][$uid])){
// $array[$uid] = strval($values['uid'][$uid]);
// }
// }
// $values['uid'] = $array;
// }
writelog('count_values:'.count($values['uid']), 'jpushnew_'.date('d') );
writelog('string:'.$string, 'jpushnew_'.date('d') );
}else{
writelog('空的ary:'.print_r($ary, 1), 'jpushnew_'.date('d') );
writelog('空的count:'.count($ary['GroupRecord']), 'jpushnew_'.date('d') );
writelog('空的values:'.json_encode($values), 'jpushnew_'.date('d') );
}
//取100条
// $values['uid'] = array_slice($values['uid'], 0, 1000, true);
return $values;
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment