Commit dc0a35bd authored by fangliyan's avatar fangliyan

PC收藏相关

parent e63fbe4b
...@@ -806,25 +806,9 @@ class User_model extends MY_Model ...@@ -806,25 +806,9 @@ class User_model extends MY_Model
if($jmz==1){ if($jmz==1){
$uidnum = $this->get_data(array('form_name' => 'personal_collection','where'=>array('passport_uid'=>$uid,'kind'=>$kind,'city_name'=>$city),'select'=>array('count(*) as num')),'esfbak'); $uidnum = $this->get_data(array('form_name' => 'personal_collection','where'=>array('passport_uid'=>$uid,'kind'=>$kind,'city_name'=>$city),'select'=>array('count(*) as num')),'esfbak');
}else{ }else{
$user_array = $this->get_data(array('form_name' => 'personal_user','where'=>array('id'=>$uid),'select'=>array('passport_uid')),'esfbak'); //获取base_id
$base_id = ''; $base_id_where = $this->get_base_id($uid,0,1);
if(!empty($user_array)){ if($base_id_where){
$passport_uid = $user_array[0]['passport_uid'];
$base_id_url = 'http://localnewrent.house365.com/api/tf-app/get-base-id?keyword='.$passport_uid;
$base_id = curl_get_contents($base_id_url);
}
$base_id_where = "'".$base_id."'";
if($base_id){
$base_id = explode(',',$base_id);
if(count($base_id)>1){
$base_id_where = '';
foreach ($base_id as $key => $value) {
$base_id_where .= "'".$value."',";
}
$base_id_where = rtrim($base_id_where,',');
}
}
if($base_id){
$uidnum = $this->get_data(array('form_name' => 'personal_collection','where'=>"base_id in ($base_id_where) and kind=$kind and city_name='$city'",'select'=>array('count(*) as num')),'esfbak'); $uidnum = $this->get_data(array('form_name' => 'personal_collection','where'=>"base_id in ($base_id_where) and kind=$kind and city_name='$city'",'select'=>array('count(*) as num')),'esfbak');
}else { }else {
$uidnum = $this->get_data(array('form_name' => 'personal_collection', 'where' => array('uid' => $uid, 'kind' => $kind, 'city_name' => $city), 'select' => array('count(*) as num')), 'esfbak'); $uidnum = $this->get_data(array('form_name' => 'personal_collection', 'where' => array('uid' => $uid, 'kind' => $kind, 'city_name' => $city), 'select' => array('count(*) as num')), 'esfbak');
...@@ -849,13 +833,20 @@ class User_model extends MY_Model ...@@ -849,13 +833,20 @@ class User_model extends MY_Model
*/ */
function getusercollectid($uid,$houseid,$city=GB_CITY,$kind="") function getusercollectid($uid,$houseid,$city=GB_CITY,$kind="")
{ {
if($kind){ $where_string = " collect_id = $houseid and city_name='$city'";
$return = $this->get_data(array('form_name' => 'personal_collection','where'=>array('uid'=>$uid,'collect_id'=>$houseid,'city_name'=>$city,'kind'=>$kind),'select'=>array('id')),'esf'); //如果有base_id优先走base_id
$base_id_where = $this->get_base_id($uid,0,1);
if($base_id_where){
$where_string .= " and base_id in ($base_id_where)";
}else{ }else{
$return = $this->get_data(array('form_name' => 'personal_collection','where'=>array('uid'=>$uid,'collect_id'=>$houseid,'city_name'=>$city),'select'=>array('id')),'esf'); $where_string .= " and uid = $uid";
}
//如果有kind
if($kind){
$where_string .= " and kind = $kind";
} }
$return = $this->get_data(array('form_name' => 'personal_collection','where'=>$where_string,'select'=>array('id')),'esf');
if(!empty($return[0])) if(!empty($return[0]))
{ {
...@@ -993,7 +984,10 @@ class User_model extends MY_Model ...@@ -993,7 +984,10 @@ class User_model extends MY_Model
*/ */
function addcollect($uid,$collect_id,$kind,$collect_value,$city=GB_CITY,$infofrom=1,$passport_uid=0) function addcollect($uid,$collect_id,$kind,$collect_value,$city=GB_CITY,$infofrom=1,$passport_uid=0)
{ {
$arr = array('uid'=>$uid,'collect_id'=>$collect_id,'kind'=>$kind,'collect_value'=>$collect_value,'collect_time'=>time(),'city_name'=>$city,'infofrom'=>$infofrom,'passport_uid'=>$passport_uid); $base_id = $this->get_base_id($uid);
//取第一个
$one_base_id = explode(',',$base_id);
$arr = array('base_id'=>$one_base_id,'uid'=>$uid,'collect_id'=>$collect_id,'kind'=>$kind,'collect_value'=>$collect_value,'collect_time'=>time(),'city_name'=>$city,'infofrom'=>$infofrom,'passport_uid'=>$passport_uid);
//设置表 //设置表
$this->user_model->set_table('personal_collection'); $this->user_model->set_table('personal_collection');
//过滤表结构 //过滤表结构
...@@ -1124,26 +1118,9 @@ class User_model extends MY_Model ...@@ -1124,26 +1118,9 @@ class User_model extends MY_Model
if(empty($collect_array) ) if(empty($collect_array) )
{ {
//获取base_id
$user_array = $this->get_data(array('form_name' => 'personal_user','where'=>array('id'=>$uid),'select'=>array('passport_uid')),'esfbak'); $base_id_where = $this->get_base_id($uid,0,1);
$base_id = ''; if($base_id_where){
if(!empty($user_array)){
$passport_uid = $user_array[0]['passport_uid'];
$base_id_url = 'http://localnewrent.house365.com/api/tf-app/get-base-id?keyword='.$passport_uid;
$base_id = curl_get_contents($base_id_url);
}
$base_id_where = "'".$base_id."'";
if($base_id){
$base_id = explode(',',$base_id);
if(count($base_id)>1){
$base_id_where = '';
foreach ($base_id as $key => $value) {
$base_id_where .= "'".$value."',";
}
$base_id_where = rtrim($base_id_where,',');
}
}
if($base_id){
$collect_array = $this->get_data(array('form_name' => 'personal_collection','where'=>"base_id in ($base_id_where) and kind=$kind and city_name='$city'",'limit'=>$pagesize,'offset'=>$offset,'order_by'=>'collect_time desc'),'esfbak'); $collect_array = $this->get_data(array('form_name' => 'personal_collection','where'=>"base_id in ($base_id_where) and kind=$kind and city_name='$city'",'limit'=>$pagesize,'offset'=>$offset,'order_by'=>'collect_time desc'),'esfbak');
}else{ }else{
$collect_array = $this->get_data(array('form_name' => 'personal_collection','where'=>array('uid'=>(int)$uid,'kind'=>$kind,'city_name'=>$city),'limit'=>$pagesize,'offset'=>$offset,'order_by'=>'collect_time desc'),'esfbak'); $collect_array = $this->get_data(array('form_name' => 'personal_collection','where'=>array('uid'=>(int)$uid,'kind'=>$kind,'city_name'=>$city),'limit'=>$pagesize,'offset'=>$offset,'order_by'=>'collect_time desc'),'esfbak');
...@@ -4696,25 +4673,9 @@ if($searcharr['infotype']==4){ ...@@ -4696,25 +4673,9 @@ if($searcharr['infotype']==4){
if( empty($block) ) if( empty($block) )
{ {
$user_array = $this->get_data(array('form_name' => 'personal_user','where'=>array('id'=>$uid),'select'=>array('passport_uid')),'esfbak'); //获取base_id
$base_id = ''; $base_id_where = $this->get_base_id($uid,0,1);
if(!empty($user_array)){ if($base_id_where){
$passport_uid = $user_array[0]['passport_uid'];
$base_id_url = 'http://localnewrent.house365.com/api/tf-app/get-base-id?keyword='.$passport_uid;
$base_id = curl_get_contents($base_id_url);
}
$base_id_where = "'".$base_id."'";
if($base_id){
$base_id = explode(',',$base_id);
if(count($base_id)>1){
$base_id_where = '';
foreach ($base_id as $key => $value) {
$base_id_where .= "'".$value."',";
}
$base_id_where = rtrim($base_id_where,',');
}
}
if($base_id){
$sql = "select collect_id from personal_collection where base_id in ($base_id_where) and city_name = '$city' and kind = 2 and collect_id <> 0 $sql = "select collect_id from personal_collection where base_id in ($base_id_where) and city_name = '$city' and kind = 2 and collect_id <> 0
order by collect_time desc "; order by collect_time desc ";
$query = $this->db_esfbak->query($sql); $query = $this->db_esfbak->query($sql);
...@@ -4732,7 +4693,7 @@ if($searcharr['infotype']==4){ ...@@ -4732,7 +4693,7 @@ if($searcharr['infotype']==4){
} }
} }
if($base_id){ if($base_id_where){
$sql = "select collect_id from personal_collection where base_id in ($base_id_where) and city_name = '$city' and kind = 3 and collect_id <> 0 $sql = "select collect_id from personal_collection where base_id in ($base_id_where) and city_name = '$city' and kind = 3 and collect_id <> 0
order by collect_time desc"; order by collect_time desc";
$query = $this->db_esfbak->query($sql); $query = $this->db_esfbak->query($sql);
...@@ -4763,7 +4724,7 @@ if($searcharr['infotype']==4){ ...@@ -4763,7 +4724,7 @@ if($searcharr['infotype']==4){
} }
} }
if($base_id){ if($base_id_where){
$sql = "select collect_id from personal_collection where base_id in ($base_id_where) and city_name = '$city' and kind = 4 and collect_id <> 0 $sql = "select collect_id from personal_collection where base_id in ($base_id_where) and city_name = '$city' and kind = 4 and collect_id <> 0
order by collect_time desc"; order by collect_time desc";
$query = $this->db_esfbak->query($sql); $query = $this->db_esfbak->query($sql);
...@@ -6366,5 +6327,45 @@ if($searcharr['infotype']==4){ ...@@ -6366,5 +6327,45 @@ if($searcharr['infotype']==4){
return $data; return $data;
} }
/**
* 获取用户信息
* @param $uid int
* @param $passport_uid int
* @param $in_where int 是否要作为sql 拼接条件
* @return string
*/
public function get_base_id($uid=0,$passport_uid=0,$in_where=0)
{
if(!$uid && !$passport_uid) return '';
if(!$passport_uid){
$user_array = $this->get_data(array('form_name' => 'personal_user','where'=>array('id'=>$uid),'select'=>array('passport_uid')),'esfbak');
if(!empty($user_array)){
$passport_uid = $user_array[0]['passport_uid'];
}else{
return '';
}
}
$base_id_url = 'http://localnewrent.house365.com/api/tf-app/get-base-id?keyword='.$passport_uid;
$base_id = curl_get_contents($base_id_url);
$res = $base_id;
if($base_id){
if($in_where){
$base_id_where = "'".$base_id."'";
$base_id = explode(',',$base_id);
if(count($base_id)>1){
$base_id_where = '';
foreach ($base_id as $key => $value) {
$base_id_where .= "'".$value."',";
}
$base_id_where = rtrim($base_id_where,',');
}
$res = $base_id_where;
}
}
return $res;
}
} }
\ No newline at end of file
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