Commit cdc23bba by 冷斌

首页

parent d64716fe
...@@ -516,11 +516,12 @@ class Api_Home extends PhalApi_Api ...@@ -516,11 +516,12 @@ class Api_Home extends PhalApi_Api
$uid = checkNull($this->uid); $uid = checkNull($this->uid);
$key = 'getRecommend'; $key = 'getRecommend';
$info = getcaches($key); // $info = getcaches($key);
$info = false;
if (!$info) { if (!$info) {
$domain = new Domain_Home(); $domain = new Domain_Home();
$info = $domain->getRecommend(); $info = $domain->getRecommend();
setcaches($key, $info, 60 * 10); // setcaches($key, $info, 60 * 10);
} }
foreach ($info as $k => $v) { foreach ($info as $k => $v) {
......
...@@ -2,20 +2,20 @@ ...@@ -2,20 +2,20 @@
session_start(); session_start();
class Model_Home extends PhalApi_Model_NotORM { class Model_Home extends PhalApi_Model_NotORM {
/* 轮播 */ /* 轮播 */
public function getSlide(){ public function getSlide(){
$rs=DI()->notorm->slide $rs=DI()->notorm->slide
->select("slide_pic,slide_url,slide_name") ->select("slide_pic,slide_url,slide_name")
->where("slide_status='1' and slide_cid='2' ") ->where("slide_status='1' and slide_cid='2' ")
->order("listorder asc") ->order("listorder asc")
->fetchAll(); ->fetchAll();
foreach($rs as $k=>$v){ foreach($rs as $k=>$v){
$rs[$k]['slide_pic']=get_upload_path($v['slide_pic']); $rs[$k]['slide_pic']=get_upload_path($v['slide_pic']);
} }
return $rs; return $rs;
} }
/* 印象标签 */ /* 印象标签 */
public function getImpressionLabel() public function getImpressionLabel()
...@@ -47,70 +47,70 @@ class Model_Home extends PhalApi_Model_NotORM { ...@@ -47,70 +47,70 @@ class Model_Home extends PhalApi_Model_NotORM {
return $l; return $l;
} }
/* 热门 */ /* 热门 */
public function getHot($p, $touids = [], $uid=0) { public function getHot($p, $touids = [], $uid=0) {
if($p<1){ if($p<1){
$p=1; $p=1;
} }
$pnum=50; $pnum=50;
$start=($p-1)*$pnum; $start=($p-1)*$pnum;
$where=" islive= '1' and ishot='1' "; $where=" islive= '1' and ishot='1' ";
if (!empty($touids)) { if (!empty($touids)) {
$touidss=implode(",",$touids); $touidss=implode(",",$touids);
$where.=" and uid in ({$touidss})"; $where.=" and uid in ({$touidss})";
} }
if($p!=1){ if($p!=1){
$endtime=$_SESSION['hot_starttime']; $endtime=$_SESSION['hot_starttime'];
if($endtime){ if($endtime){
$where.=" and starttime < {$endtime}"; $where.=" and starttime < {$endtime}";
} }
} }
$configpri=getConfigPri(); $configpri=getConfigPri();
$result=DI()->notorm->users_live $result=DI()->notorm->users_live
->select("uid,title,city,stream,pull,thumb,isvideo,type,type_val,game_action,goodnum,anyway") ->select("uid,title,city,stream,pull,thumb,isvideo,type,type_val,game_action,goodnum,anyway")
->where($where) ->where($where)
->order('hotvotes desc,starttime desc') ->order('hotvotes desc,starttime desc')
->limit($start,$pnum) ->limit($start,$pnum)
->fetchAll(); ->fetchAll();
foreach($result as $k=>$v){ foreach($result as $k=>$v){
$nums=DI()->redis->zSize('user_'.$v['stream']); $nums=DI()->redis->zSize('user_'.$v['stream']);
$v['nums']=(string)$nums; $v['nums']=(string)$nums;
$userinfo=getUserInfo($v['uid']); $userinfo=getUserInfo($v['uid']);
$v['avatar']=$userinfo['avatar']; $v['avatar']=$userinfo['avatar'];
$v['avatar_thumb']=$userinfo['avatar_thumb']; $v['avatar_thumb']=$userinfo['avatar_thumb'];
$v['user_nicename']=$userinfo['user_nicename']; $v['user_nicename']=$userinfo['user_nicename'];
$v['sex']=$userinfo['sex']; $v['sex']=$userinfo['sex'];
$v['level']=$userinfo['level']; $v['level']=$userinfo['level'];
$v['level_anchor']=$userinfo['level_anchor']; $v['level_anchor']=$userinfo['level_anchor'];
$v['game']=getGame($v['game_action']); $v['game']=getGame($v['game_action']);
if(!$v['thumb']){ if(!$v['thumb']){
$v['thumb']=$v['avatar']; $v['thumb']=$v['avatar'];
} }
if($v['isvideo']==0 && $configpri['cdn_switch']!=5){ if($v['isvideo']==0 && $configpri['cdn_switch']!=5){
$v['pull']=PrivateKeyA('rtmp',$v['stream'],0); $v['pull']=PrivateKeyA('rtmp',$v['stream'],0);
} }
if($v['type']==1){ if($v['type']==1){
$v['type_val']=''; $v['type_val']='';
} }
$result[$k]=$v; $result[$k]=$v;
} }
if($result){ if($result){
$last=end($result); $last=end($result);
$_SESSION['hot_starttime']=$last['starttime']; $_SESSION['hot_starttime']=$last['starttime'];
} }
return $result; return $result;
} }
...@@ -175,7 +175,7 @@ class Model_Home extends PhalApi_Model_NotORM { ...@@ -175,7 +175,7 @@ class Model_Home extends PhalApi_Model_NotORM {
return $data; return $data;
} }
/* 关注列表 */ /* 关注列表 */
public function getFollow($uid,$p) { public function getFollow($uid,$p) {
$rs=array( $rs=array(
'title'=>'你还没有关注任何主播', 'title'=>'你还没有关注任何主播',
...@@ -185,16 +185,16 @@ class Model_Home extends PhalApi_Model_NotORM { ...@@ -185,16 +185,16 @@ class Model_Home extends PhalApi_Model_NotORM {
if($p<1){ if($p<1){
$p=1; $p=1;
} }
$result=array(); $result=array();
$pnum=50; $pnum=50;
$start=($p-1)*$pnum; $start=($p-1)*$pnum;
$configpri=getConfigPri(); $configpri=getConfigPri();
$touid=DI()->notorm->users_attention $touid=DI()->notorm->users_attention
->select("touid") ->select("touid")
->where('uid=?',$uid) ->where('uid=?',$uid)
->fetchAll(); ->fetchAll();
if($touid){ if($touid){
$rs['title']='你关注的主播没有开播'; $rs['title']='你关注的主播没有开播';
$rs['des']='赶快去看看其他主播的直播吧~'; $rs['des']='赶快去看看其他主播的直播吧~';
$where=" islive='1' "; $where=" islive='1' ";
...@@ -206,51 +206,51 @@ class Model_Home extends PhalApi_Model_NotORM { ...@@ -206,51 +206,51 @@ class Model_Home extends PhalApi_Model_NotORM {
} }
} }
$touids=array_column($touid,"touid"); $touids=array_column($touid,"touid");
$touidss=implode(",",$touids); $touidss=implode(",",$touids);
$where.=" and uid in ({$touidss})"; $where.=" and uid in ({$touidss})";
$result=DI()->notorm->users_live $result=DI()->notorm->users_live
->select("uid,title,city,stream,pull,thumb,isvideo,type,type_val,game_action,goodnum,anyway,starttime") ->select("uid,title,city,stream,pull,thumb,isvideo,type,type_val,game_action,goodnum,anyway,starttime")
->where($where) ->where($where)
->order("starttime desc") ->order("starttime desc")
->limit($start,$pnum) ->limit($start,$pnum)
->fetchAll(); ->fetchAll();
} }
foreach($result as $k=>$v){ foreach($result as $k=>$v){
$nums=DI()->redis->zSize('user_'.$v['stream']); $nums=DI()->redis->zSize('user_'.$v['stream']);
$v['nums']=(string)$nums; $v['nums']=(string)$nums;
$userinfo=getUserInfo($v['uid']); $userinfo=getUserInfo($v['uid']);
$v['avatar']=$userinfo['avatar']; $v['avatar']=$userinfo['avatar'];
$v['avatar_thumb']=$userinfo['avatar_thumb']; $v['avatar_thumb']=$userinfo['avatar_thumb'];
$v['user_nicename']=$userinfo['user_nicename']; $v['user_nicename']=$userinfo['user_nicename'];
$v['sex']=$userinfo['sex']; $v['sex']=$userinfo['sex'];
$v['level']=$userinfo['level']; $v['level']=$userinfo['level'];
$v['level_anchor']=$userinfo['level_anchor']; $v['level_anchor']=$userinfo['level_anchor'];
$v['game']=getGame($v['game_action']); $v['game']=getGame($v['game_action']);
if(!$v['thumb']){ if(!$v['thumb']){
$v['thumb']=$v['avatar']; $v['thumb']=$v['avatar'];
} }
if($v['isvideo']==0 && $configpri['cdn_switch']!=5){ if($v['isvideo']==0 && $configpri['cdn_switch']!=5){
$v['pull']=PrivateKeyA('rtmp',$v['stream'],0); $v['pull']=PrivateKeyA('rtmp',$v['stream'],0);
} }
if($v['type']==1){ if($v['type']==1){
$v['type_val']=''; $v['type_val']='';
} }
$result[$k]=$v; $result[$k]=$v;
} }
if($result){ if($result){
$last=end($result); $last=end($result);
$_SESSION['follow_starttime']=$last['starttime']; $_SESSION['follow_starttime']=$last['starttime'];
} }
$rs['list']=$result; $rs['list']=$result;
return $rs; return $rs;
} }
/** /**
...@@ -325,102 +325,102 @@ class Model_Home extends PhalApi_Model_NotORM { ...@@ -325,102 +325,102 @@ class Model_Home extends PhalApi_Model_NotORM {
/* 最新 */ /* 最新 */
public function getNew($lng,$lat,$p) { public function getNew($lng,$lat,$p) {
if($p<1){ if($p<1){
$p=1; $p=1;
} }
$pnum=50; $pnum=50;
$start=($p-1)*$pnum; $start=($p-1)*$pnum;
$where=" islive='1' "; $where=" islive='1' ";
if($p!=1){ if($p!=1){
$endtime=$_SESSION['new_starttime']; $endtime=$_SESSION['new_starttime'];
if($endtime){ if($endtime){
$where.=" and starttime < {$endtime}"; $where.=" and starttime < {$endtime}";
} }
} }
$configpri=getConfigPri(); $configpri=getConfigPri();
$result=DI()->notorm->users_live $result=DI()->notorm->users_live
->select("uid,title,city,stream,lng,lat,pull,thumb,isvideo,type,type_val,game_action,goodnum,anyway,starttime") ->select("uid,title,city,stream,lng,lat,pull,thumb,isvideo,type,type_val,game_action,goodnum,anyway,starttime")
->where($where) ->where($where)
->order("starttime desc") ->order("starttime desc")
->limit($start,$pnum) ->limit($start,$pnum)
->fetchAll(); ->fetchAll();
foreach($result as $k=>$v){ foreach($result as $k=>$v){
$nums=DI()->redis->zSize('user_'.$v['stream']); $nums=DI()->redis->zSize('user_'.$v['stream']);
$v['nums']=(string)$nums; $v['nums']=(string)$nums;
$userinfo=getUserInfo($v['uid']); $userinfo=getUserInfo($v['uid']);
$v['avatar']=$userinfo['avatar']; $v['avatar']=$userinfo['avatar'];
$v['avatar_thumb']=$userinfo['avatar_thumb']; $v['avatar_thumb']=$userinfo['avatar_thumb'];
$v['user_nicename']=$userinfo['user_nicename']; $v['user_nicename']=$userinfo['user_nicename'];
$v['sex']=$userinfo['sex']; $v['sex']=$userinfo['sex'];
$v['level']=$userinfo['level']; $v['level']=$userinfo['level'];
$v['level_anchor']=$userinfo['level_anchor']; $v['level_anchor']=$userinfo['level_anchor'];
$v['game']=getGame($v['game_action']); $v['game']=getGame($v['game_action']);
if(!$v['thumb']){ if(!$v['thumb']){
$v['thumb']=$v['avatar']; $v['thumb']=$v['avatar'];
} }
if($v['isvideo']==0 && $configpri['cdn_switch']!=5){ if($v['isvideo']==0 && $configpri['cdn_switch']!=5){
$v['pull']=PrivateKeyA('rtmp',$v['stream'],0); $v['pull']=PrivateKeyA('rtmp',$v['stream'],0);
} }
if($v['type']==1){ if($v['type']==1){
$v['type_val']=''; $v['type_val']='';
} }
$distance='好像在火星'; $distance='好像在火星';
if($lng!='' && $lat!='' && $v['lat']!='' && $v['lng']!=''){ if($lng!='' && $lat!='' && $v['lat']!='' && $v['lng']!=''){
$distance=getDistance($lat,$lng,$v['lat'],$v['lng']); $distance=getDistance($lat,$lng,$v['lat'],$v['lng']);
}else if($v['city']){ }else if($v['city']){
$distance=$v['city']; $distance=$v['city'];
} }
$v['distance']=$distance; $v['distance']=$distance;
unset($v['lng']); unset($v['lng']);
unset($v['lat']); unset($v['lat']);
$result[$k]=$v; $result[$k]=$v;
} }
if($result){ if($result){
$last=end($result); $last=end($result);
$_SESSION['new_starttime']=$last['starttime']; $_SESSION['new_starttime']=$last['starttime'];
} }
return $result; return $result;
} }
/* 搜索 */ /* 搜索 */
public function search($uid,$key,$p,$type) { public function search($uid,$key,$p,$type) {
if($p<1){ if($p<1){
$p=1; $p=1;
} }
$pnum=50; $pnum=50;
$start=($p-1)*$pnum; $start=($p-1)*$pnum;
$where=' user_type="2" and ( id=? or user_nicename like ? or goodnum like ? ) and id!=?'; $where=' user_type="2" and ( id=? or user_nicename like ? or goodnum like ? ) and id!=?';
if($p!=1){ if($p!=1){
$id=$_SESSION['search']; $id=$_SESSION['search'];
if($id){ if($id){
$where.=" and id < {$id}"; $where.=" and id < {$id}";
} }
} }
$result=DI()->notorm->users $result=DI()->notorm->users
->select("id,user_nicename,avatar,sex,signature,consumption,votestotal") ->select("id,user_nicename,avatar,sex,signature,consumption,votestotal")
->where($where,$key,'%'.$key.'%','%'.$key.'%',$uid) ->where($where,$key,'%'.$key.'%','%'.$key.'%',$uid)
->order("id desc") ->order("id desc")
->limit($start,$pnum) ->limit($start,$pnum)
->fetchAll(); ->fetchAll();
foreach($result as $k=>$v){ foreach($result as $k=>$v){
$v['level']=(string)getLevel($v['consumption']); $v['level']=(string)getLevel($v['consumption']);
$v['level_anchor']=(string)getLevelAnchor($v['votestotal']); $v['level_anchor']=(string)getLevelAnchor($v['votestotal']);
$v['isattention']=(string)isAttention($uid,$v['id']); $v['isattention']=(string)isAttention($uid,$v['id']);
$v['avatar']=get_upload_path($v['avatar']); $v['avatar']=get_upload_path($v['avatar']);
unset($v['consumption']); unset($v['consumption']);
$touids=DI()->notorm->users_attention $touids=DI()->notorm->users_attention
->where('touid=?',$v['id']) ->where('touid=?',$v['id'])
->count(); ->count();
...@@ -435,14 +435,14 @@ class Model_Home extends PhalApi_Model_NotORM { ...@@ -435,14 +435,14 @@ class Model_Home extends PhalApi_Model_NotORM {
$v['type']=$type; $v['type']=$type;
} }
$result[$k]=$v; $result[$k]=$v;
} }
if($result){ if($result){
$last=end($result); $last=end($result);
$_SESSION['search']=$last['id']; $_SESSION['search']=$last['id'];
} }
return $result; return $result;
} }
/** /**
...@@ -498,116 +498,154 @@ class Model_Home extends PhalApi_Model_NotORM { ...@@ -498,116 +498,154 @@ class Model_Home extends PhalApi_Model_NotORM {
return $rs; return $rs;
} }
/* 附近 */ /* 附近 */
public function getNearby($lng,$lat,$p) { public function getNearby($lng,$lat,$p) {
if($p<1){ if($p<1){
$p=1; $p=1;
} }
$pnum=50; $pnum=50;
$start=($p-1)*$pnum; $start=($p-1)*$pnum;
$where=" islive='1' and lng!='' and lat!='' "; $where=" islive='1' and lng!='' and lat!='' ";
$configpri=getConfigPri(); $configpri=getConfigPri();
$result=DI()->notorm->users_live $result=DI()->notorm->users_live
->select("uid,title,province,city,stream,lng,lat,pull,isvideo,thumb,islive,type,type_val,game_action,goodnum,anyway,getDistance('{$lat}','{$lng}',lat,lng) as distance") ->select("uid,title,province,city,stream,lng,lat,pull,isvideo,thumb,islive,type,type_val,game_action,goodnum,anyway,getDistance('{$lat}','{$lng}',lat,lng) as distance")
->where($where) ->where($where)
->order("distance asc") ->order("distance asc")
->limit($start,$pnum) ->limit($start,$pnum)
->fetchAll(); ->fetchAll();
foreach($result as $k=>$v){ foreach($result as $k=>$v){
$nums=DI()->redis->zSize('user_'.$v['stream']); $nums=DI()->redis->zSize('user_'.$v['stream']);
$v['nums']=(string)$nums; $v['nums']=(string)$nums;
$userinfo=getUserInfo($v['uid']); $userinfo=getUserInfo($v['uid']);
$v['avatar']=$userinfo['avatar']; $v['avatar']=$userinfo['avatar'];
$v['avatar_thumb']=$userinfo['avatar_thumb']; $v['avatar_thumb']=$userinfo['avatar_thumb'];
$v['user_nicename']=$userinfo['user_nicename']; $v['user_nicename']=$userinfo['user_nicename'];
$v['sex']=$userinfo['sex']; $v['sex']=$userinfo['sex'];
$v['level']=$userinfo['level']; $v['level']=$userinfo['level'];
$v['level_anchor']=$userinfo['level_anchor']; $v['level_anchor']=$userinfo['level_anchor'];
$v['game']=getGame($v['game_action']); $v['game']=getGame($v['game_action']);
if(!$v['thumb']){ if(!$v['thumb']){
$v['thumb']=$v['avatar']; $v['thumb']=$v['avatar'];
} }
if($v['isvideo']==0 && $configpri['cdn_switch']!=5){ if($v['isvideo']==0 && $configpri['cdn_switch']!=5){
$v['pull']=PrivateKeyA('rtmp',$v['stream'],0); $v['pull']=PrivateKeyA('rtmp',$v['stream'],0);
} }
if($v['type']==1){ if($v['type']==1){
$v['type_val']=''; $v['type_val']='';
} }
if($v['distance']>1000){ if($v['distance']>1000){
$v['distance']=1000; $v['distance']=1000;
} }
$v['distance']=$v['distance'].'km'; $v['distance']=$v['distance'].'km';
$result[$k]=$v; $result[$k]=$v;
} }
return $result; return $result;
} }
/* 推荐 */ /* 推荐 */
public function getRecommend(){ public function getRecommend(){
$configpri=getConfigPri();
$where=" isrecommend = '1' and islive= '1' and ishot='1' ";
$result=DI()->notorm->users_live
->select("uid,title,city,stream,pull,thumb,isvideo,type,type_val,game_action,goodnum,anyway")
->where($where)
->order('starttime desc')
->limit(50)
->fetchAll();
foreach($result as $k=>$v){
$nums=DI()->redis->zSize('user_'.$v['stream']);
$v['nums']=(string)$nums;
$userinfo=getUserInfo($v['uid']);
$v['avatar']=$userinfo['avatar'];
$v['avatar_thumb']=$userinfo['avatar_thumb'];
$v['user_nicename']=$userinfo['user_nicename'];
$v['sex']=$userinfo['sex'];
$v['level']=$userinfo['level'];
$v['level_anchor']=$userinfo['level_anchor'];
$v['game']=getGame($v['game_action']);
if(!$v['thumb']){
$v['thumb']=$v['avatar'];
}
if($v['isvideo']==0 && $configpri['cdn_switch']!=5){
$v['pull']=PrivateKeyA('rtmp',$v['stream'],0);
}
$result=DI()->notorm->users if($v['type']==1){
->select("id,user_nicename,avatar,avatar_thumb") $v['type_val']='';
->where("isrecommend='1'") }
->order("votestotal desc") $v['ifpk'] = DI()->redis -> hGet('LiveConnect',$v['uid']) ? 1 : 0;
->limit(50)
->fetchAll();
foreach($result as $k=>$v){
$v['avatar']=get_upload_path($v['avatar']);
$v['avatar_thumb']=get_upload_path($v['avatar_thumb']);
$fans=getFans($v['id']);
$v['fans']='粉丝 · '.$fans;
$result[$k]=$v; $result[$k]=$v;
} }
return $result;
} // $result=DI()->notorm->users
/* 关注推荐 */ // ->select("id,user_nicename,avatar,avatar_thumb")
public function attentRecommend($uid,$touids){ // ->where("isrecommend='1'")
//$users=$this->getRecommend(); // ->order("votestotal desc")
//$users=explode(',',$touids); // ->limit(50)
// ->fetchAll();
// foreach($result as $k=>$v){
// $v['avatar']=get_upload_path($v['avatar']);
// $v['avatar_thumb']=get_upload_path($v['avatar_thumb']);
// $fans=getFans($v['id']);
// $v['fans']='粉丝 · '.$fans;
//
// $result[$k]=$v;
// }
return $result;
}
/* 关注推荐 */
public function attentRecommend($uid,$touids){
//$users=$this->getRecommend();
//$users=explode(',',$touids);
file_put_contents('./attentRecommend.txt',date('Y-m-d H:i:s').' 提交参数信息 touids:'.$touids."\r\n",FILE_APPEND); file_put_contents('./attentRecommend.txt',date('Y-m-d H:i:s').' 提交参数信息 touids:'.$touids."\r\n",FILE_APPEND);
$users=preg_split('/,|,/',$touids); $users=preg_split('/,|,/',$touids);
foreach($users as $k=>$v){ foreach($users as $k=>$v){
$touid=$v; $touid=$v;
file_put_contents('./attentRecommend.txt',date('Y-m-d H:i:s').' 提交参数信息 touid:'.$touid."\r\n",FILE_APPEND); file_put_contents('./attentRecommend.txt',date('Y-m-d H:i:s').' 提交参数信息 touid:'.$touid."\r\n",FILE_APPEND);
if($touid && !isAttention($uid,$touid)){ if($touid && !isAttention($uid,$touid)){
DI()->notorm->users_black DI()->notorm->users_black
->where('uid=? and touid=?',$uid,$touid) ->where('uid=? and touid=?',$uid,$touid)
->delete(); ->delete();
DI()->notorm->users_attention DI()->notorm->users_attention
->insert(array("uid"=>$uid,"touid"=>$touid)); ->insert(array("uid"=>$uid,"touid"=>$touid));
} }
} }
return 1; return 1;
} }
/*获取收益排行榜*/ /*获取收益排行榜*/
public function profitList($uid,$type,$p){ public function profitList($uid,$type,$p){
if($p<1){ if($p<1){
$p=1; $p=1;
} }
$pnum=50; $pnum=50;
$start=($p-1)*$pnum; $start=($p-1)*$pnum;
switch ($type) { switch ($type) {
case 'day': case 'day':
//获取今天开始结束时间 //获取今天开始结束时间
$dayStart=strtotime(date("Y-m-d")); $dayStart=strtotime(date("Y-m-d"));
$dayEnd=strtotime(date("Y-m-d 23:59:59")); $dayEnd=strtotime(date("Y-m-d 23:59:59"));
$where=" addtime >={$dayStart} and addtime<={$dayEnd} and "; $where=" addtime >={$dayStart} and addtime<={$dayEnd} and ";
break; break;
case 'week': case 'week':
$w=date('w'); $w=date('w');
//获取本周开始日期,如果$w是0,则表示周日,减去 6 天 //获取本周开始日期,如果$w是0,则表示周日,减去 6 天
$first=1; $first=1;
...@@ -619,11 +657,11 @@ class Model_Home extends PhalApi_Model_NotORM { ...@@ -619,11 +657,11 @@ class Model_Home extends PhalApi_Model_NotORM {
//周天 //周天
$week_end=strtotime("{$week} +1 week")-1; $week_end=strtotime("{$week} +1 week")-1;
$where=" addtime >={$week_start} and addtime<={$week_end} and "; $where=" addtime >={$week_start} and addtime<={$week_end} and ";
break; break;
case 'month': case 'month':
//本月第一天 //本月第一天
$month=date('Y-m-d',strtotime(date("Ym").'01')); $month=date('Y-m-d',strtotime(date("Ym").'01'));
$month_start=strtotime(date("Ym").'01'); $month_start=strtotime(date("Ym").'01');
...@@ -631,25 +669,25 @@ class Model_Home extends PhalApi_Model_NotORM { ...@@ -631,25 +669,25 @@ class Model_Home extends PhalApi_Model_NotORM {
//本月最后一天 //本月最后一天
$month_end=strtotime("{$month} +1 month")-1; $month_end=strtotime("{$month} +1 month")-1;
$where=" addtime >={$month_start} and addtime<={$month_end} and "; $where=" addtime >={$month_start} and addtime<={$month_end} and ";
break; break;
case 'total': case 'total':
$where=" "; $where=" ";
break; break;
default: default:
//获取今天开始结束时间 //获取今天开始结束时间
$dayStart=strtotime(date("Y-m-d")); $dayStart=strtotime(date("Y-m-d"));
$dayEnd=strtotime(date("Y-m-d 23:59:59")); $dayEnd=strtotime(date("Y-m-d 23:59:59"));
$where=" addtime >={$dayStart} and addtime<={$dayEnd} and "; $where=" addtime >={$dayStart} and addtime<={$dayEnd} and ";
break; break;
} }
$where.=" type='expend' and action in ('sendgift','sendbarrage')"; $where.=" type='expend' and action in ('sendgift','sendbarrage')";
$result=DI()->notorm->users_coinrecord $result=DI()->notorm->users_coinrecord
->select('sum(totalcoin) as totalcoin,touid as uid') ->select('sum(totalcoin) as totalcoin,touid as uid')
->where($where) ->where($where)
->group('touid') ->group('touid')
...@@ -657,23 +695,23 @@ class Model_Home extends PhalApi_Model_NotORM { ...@@ -657,23 +695,23 @@ class Model_Home extends PhalApi_Model_NotORM {
->limit($start,$pnum) ->limit($start,$pnum)
->fetchAll(); ->fetchAll();
foreach ($result as $k => $v) { foreach ($result as $k => $v) {
$userinfo=getUserInfo($v['uid']); $userinfo=getUserInfo($v['uid']);
$v['avatar']=$userinfo['avatar']; $v['avatar']=$userinfo['avatar'];
$v['avatar_thumb']=$userinfo['avatar_thumb']; $v['avatar_thumb']=$userinfo['avatar_thumb'];
$v['user_nicename']=$userinfo['user_nicename']; $v['user_nicename']=$userinfo['user_nicename'];
$v['sex']=$userinfo['sex']; $v['sex']=$userinfo['sex'];
$v['level']=$userinfo['level']; $v['level']=$userinfo['level'];
$v['level_anchor']=$userinfo['level_anchor']; $v['level_anchor']=$userinfo['level_anchor'];
$v['isAttention']=isAttention($uid,$v['uid']);//判断当前用户是否关注了该主播 $v['isAttention']=isAttention($uid,$v['uid']);//判断当前用户是否关注了该主播
$result[$k]=$v; $result[$k]=$v;
} }
return $result; return $result;
} }
public function star($type) public function star($type)
{ {
...@@ -904,21 +942,21 @@ class Model_Home extends PhalApi_Model_NotORM { ...@@ -904,21 +942,21 @@ class Model_Home extends PhalApi_Model_NotORM {
} }
/*获取消费排行榜*/ /*获取消费排行榜*/
public function consumeList($uid,$type,$p){ public function consumeList($uid,$type,$p){
if($p<1){ if($p<1){
$p=1; $p=1;
} }
$pnum=50; $pnum=50;
$start=($p-1)*$pnum; $start=($p-1)*$pnum;
switch ($type) { switch ($type) {
case 'day': case 'day':
//获取今天开始结束时间 //获取今天开始结束时间
$dayStart=strtotime(date("Y-m-d")); $dayStart=strtotime(date("Y-m-d"));
$dayEnd=strtotime(date("Y-m-d 23:59:59")); $dayEnd=strtotime(date("Y-m-d 23:59:59"));
$where=" addtime >={$dayStart} and addtime<={$dayEnd} and "; $where=" addtime >={$dayStart} and addtime<={$dayEnd} and ";
break; break;
case 'week': case 'week':
$w=date('w'); $w=date('w');
...@@ -932,11 +970,11 @@ class Model_Home extends PhalApi_Model_NotORM { ...@@ -932,11 +970,11 @@ class Model_Home extends PhalApi_Model_NotORM {
//周天 //周天
$week_end=strtotime("{$week} +1 week")-1; $week_end=strtotime("{$week} +1 week")-1;
$where=" addtime >={$week_start} and addtime<={$week_end} and "; $where=" addtime >={$week_start} and addtime<={$week_end} and ";
break; break;
case 'month': case 'month':
//本月第一天 //本月第一天
$month=date('Y-m-d',strtotime(date("Ym").'01')); $month=date('Y-m-d',strtotime(date("Ym").'01'));
$month_start=strtotime(date("Ym").'01'); $month_start=strtotime(date("Ym").'01');
...@@ -944,23 +982,23 @@ class Model_Home extends PhalApi_Model_NotORM { ...@@ -944,23 +982,23 @@ class Model_Home extends PhalApi_Model_NotORM {
//本月最后一天 //本月最后一天
$month_end=strtotime("{$month} +1 month")-1; $month_end=strtotime("{$month} +1 month")-1;
$where=" addtime >={$month_start} and addtime<={$month_end} and "; $where=" addtime >={$month_start} and addtime<={$month_end} and ";
break; break;
case 'total': case 'total':
$where=" "; $where=" ";
break; break;
default: default:
//获取今天开始结束时间 //获取今天开始结束时间
$dayStart=strtotime(date("Y-m-d")); $dayStart=strtotime(date("Y-m-d"));
$dayEnd=strtotime(date("Y-m-d 23:59:59")); $dayEnd=strtotime(date("Y-m-d 23:59:59"));
$where=" addtime >={$dayStart} and addtime<={$dayEnd} and "; $where=" addtime >={$dayStart} and addtime<={$dayEnd} and ";
break; break;
} }
$where.=" type='expend' and action in ('sendgift','sendbarrage')"; $where.=" type='expend' and action in ('sendgift','sendbarrage')";
$result=DI()->notorm->users_coinrecord $result=DI()->notorm->users_coinrecord
->select('sum(totalcoin) as totalcoin, uid') ->select('sum(totalcoin) as totalcoin, uid')
...@@ -970,22 +1008,22 @@ class Model_Home extends PhalApi_Model_NotORM { ...@@ -970,22 +1008,22 @@ class Model_Home extends PhalApi_Model_NotORM {
->limit($start,$pnum) ->limit($start,$pnum)
->fetchAll(); ->fetchAll();
foreach ($result as $k => $v) { foreach ($result as $k => $v) {
$userinfo=getUserInfo($v['uid']); $userinfo=getUserInfo($v['uid']);
$v['avatar']=$userinfo['avatar']; $v['avatar']=$userinfo['avatar'];
$v['avatar_thumb']=$userinfo['avatar_thumb']; $v['avatar_thumb']=$userinfo['avatar_thumb'];
$v['user_nicename']=$userinfo['user_nicename']; $v['user_nicename']=$userinfo['user_nicename'];
$v['sex']=$userinfo['sex']; $v['sex']=$userinfo['sex'];
$v['level']=$userinfo['level']; $v['level']=$userinfo['level'];
$v['level_anchor']=$userinfo['level_anchor']; $v['level_anchor']=$userinfo['level_anchor'];
$v['isAttention']=isAttention($uid,$v['uid']);//判断当前用户是否关注了该主播 $v['isAttention']=isAttention($uid,$v['uid']);//判断当前用户是否关注了该主播
$result[$k]=$v; $result[$k]=$v;
} }
return $result; return $result;
} }
/* 分类下直播 */ /* 分类下直播 */
// public function getClassLive($liveclassid,$p) { // public function getClassLive($liveclassid,$p) {
...@@ -1170,7 +1208,7 @@ class Model_Home extends PhalApi_Model_NotORM { ...@@ -1170,7 +1208,7 @@ class Model_Home extends PhalApi_Model_NotORM {
case 1: case 1:
$start = ' 00:00:00'; $start = ' 00:00:00';
$end = ' 02:59:59'; $end = ' 02:59:59';
break; break;
case 2: case 2:
$start = ' 03:00:00'; $start = ' 03:00:00';
$end = ' 05:59:59'; $end = ' 05:59:59';
......
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