| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344 |
- <?php
- namespace App\Model;
- use PhalApi\Model\NotORMModel as NotORM;
- use think\facade\Db;
- session_start();
- class Home extends NotORM{
- /* 搜索 */
- public function search($uid,$key,$city,$p) {
- $pnum=50;
- $start=($p-1)*$pnum;
- $where=' user_type="2" and user_status=1 and ( id=? or user_nickname like ?) and id!=?';
- if($p!=1){
- $id=$_SESSION['search'];
- $where.=" and id < {$id}";
- }
-
- if($city!=''){
- $where.=" and city like '%{$city}%'";
- }
-
- $result=\PhalApi\DI()->notorm->user
- ->select("id,user_nickname,avatar,avatar_thumb,sex,signature,province,city,birthday,age")
- ->where($where,$key,'%'.$key.'%',$uid)
- ->order("id desc")
- ->limit($start,$pnum)
- ->fetchAll();
- foreach($result as $k=>$v){
- $result[$k]['isattention']=(string)\App\isAttention($uid,$v['id']);
- $result[$k]['avatar']=\App\get_upload_path($v['avatar']);
- $result[$k]['avatar_thumb']=\App\get_upload_path($v['avatar_thumb']);
- if($v['age']<0){
- $result[$k]['age']=\PhalApi\T("年龄未填写");
- }else{
- $result[$k]['age'].=\PhalApi\T("岁");
- }
- if($v['city']==""){
- $result[$k]['city']=\PhalApi\T("城市未填写");
- }
- $result[$k]['praise']=\App\getPraises($v['id']);
- $result[$k]['fans']=\App\getFans($v['id']);
- $result[$k]['follows']=\App\getFollows($v['id']);
- $result[$k]['coin']="0";
- unset($result[$k]['consumption']);
- }
- if($result){
- $last=array_slice($result,-1,1);
- $_SESSION['search']=$last[0]['id'];
- }
-
- return $result;
- }
- public function videoSearch($uid,$key,$lng,$lat,$city,$p) {
- $pnum=50;
- $start=($p-1)*$pnum;
- $where="v.isdel=0 and v.status=1 and v.is_ad=0";
- $where.=' and (v.title like "%'.$key.'%" or u.user_nickname like "%'.$key.'%")';
-
- if($lng!='' && $lat!='' && $city!=''){
- $where.=" and v.city like '%{$city}%'";
- }
- /*if($p!=1){
- $id=$_SESSION['videosearch'];
- $where.=" and v.id < {$id}";
- }*/
- $prefix= \PhalApi\DI()->config->get('dbs.tables.__default__.prefix');
- $result=\PhalApi\DI()->notorm->user_video
- ->queryAll("select v.*,u.user_nickname,u.avatar from {$prefix}user_video v left join {$prefix}user u on v.uid=u.id where {$where} order by v.addtime desc limit {$start},{$pnum}");
- /*if($result){
- $last=array_slice($result,-1,1);
- $_SESSION['videosearch']=$last['id'];
- }*/
- //敏感词树
- $tree=\App\trieTreeBasic();
- foreach ($result as $k => $v) {
-
- $v=\App\handleVideo($uid,$v,$tree);
-
- $result[$k]=$v;
- }
-
- return $result;
- }
- /* 轮播 */
- public function getSlide($where){
- $rs=\PhalApi\DI()->notorm->slide_item
- ->select("image as slide_pic,url as slide_url")
- ->where($where)
- ->order("list_order asc")
- ->fetchAll();
- foreach($rs as $k=>$v){
- $rs[$k]['slide_pic']=\App\get_upload_path($v['slide_pic']);
- }
- return $rs;
- }
- /*商城-商品列表*/
- public function getShopList($p){
- $order="isrecom desc,sale_nums desc,id desc";
-
- $where=[];
- $where['status']=1;
- $list=\App\handleGoodsList($where,$p,$order);
- foreach ($list as $k => $v) {
- unset($list[$k]['specs']);
- }
- return $list;
- }
- /* 获取新闻列表*/
- public function getNewsList($p){
- $where='status=1';
- $list=\App\getNewsList($where,$p);
- return $list;
- }
- public function getNewsDetail($id){
- $where=['id'=>$id];
- $info=\App\getNewsDetail($where);
- return $info;
- }
- public function getClassidShopLists($type,$province,$name,$p){
- // $where=['type'=>$type];
- $where['type'] = $type;
- //
- // $where="type={$type} ";
- if(!empty($province)){
- $where['province'] = $province;
- }
- if(!empty($name)){
- // $where['province'] = $province;
- // $where .= " and name like '%{$name}%' " ;
- }
- $info=\App\getClassidShopLists($where,$name,$p);
- return $info;
- }
- public function getShopAddressList(){
- $info=\App\getShopAddressList();
- return $info;
- }
- /*商城-一级分类商品列表*/
- public function getShopGoodsList($p,$shopclassid){
- $order="isrecom desc,sale_nums desc,id desc";
- $where=[];
- $where['status']=1;
- $list=\App\handleGoodsList($where,$p,$order,$shopclassid);
- foreach ($list as $k => $v) {
- unset($list[$k]['specs']);
- }
- return $list;
- }
- /*商城-获取普通 助农 特价等商品列表*/
- public function getShopClassGoodsList($p,$type){
- $order="isrecom desc,sale_nums desc,id desc";
- $where=[];
- $where['status']=1;
- $list=\App\handleGoodsList($where,$p,$order,'',$type);
- foreach ($list as $k => $v) {
- unset($list[$k]['specs']);
- }
- return $list;
- }
- /*商城-推荐商品*/
- public function getRecomGoodsList(){
- $order="isrecom desc,sale_nums desc,id desc";
- $where=[];
- $where['status']=1;
- $list=\App\handleGoodsList($where,1,$order,'',1,1);
- foreach ($list as $k => $v) {
- unset($list[$k]['specs']);
- }
- return $list;
- }
- /*商城-获取分类下的商品*/
- public function getShopClassList($shopclassid,$sell,$price,$isnew,$p){
- $order=""; //排序
- $where="status=1 and three_classid={$shopclassid} ";
- if($isnew){
- //获取今天开始结束时间
- $dayStart=strtotime(date('Y-m-d',strtotime('-2 day')));
- $dayEnd=strtotime(date("Y-m-d 23:59:59"));
- $where.="and addtime >={$dayStart} and addtime<={$dayEnd}";
- }
- if($sell!=''){
- $order.="sale_nums {$sell},";
- }else if($price!=''){
- $order.="low_price {$price},";
- }
- $order.="id desc";
- $list=\App\handleGoodsList($where,$p,$order,'',4,0);
- foreach ($list as $k => $v) {
- unset($list[$k]['specs']);
- }
- return $list;
- }
- /*商城-获取分类下的商品*/
- public function getShopOneClassGoodsList($shopclassid,$sell,$price,$isnew,$p){
- $order=""; //排序
- $where="status=1 and one_classid={$shopclassid} ";
- if($isnew){
- //获取今天开始结束时间
- $dayStart=strtotime(date('Y-m-d',strtotime('-2 day')));
- $dayEnd=strtotime(date("Y-m-d 23:59:59"));
- $where.="and addtime >={$dayStart} and addtime<={$dayEnd}";
- }
- if($sell!=''){
- $order.="sale_nums {$sell},";
- }else if($price!=''){
- $order.="low_price {$price},";
- }
- $order.="id desc";
- $list=\App\handleGoodsList($where,$p,$order);
- foreach ($list as $k => $v) {
- unset($list[$k]['specs']);
- }
- return $list;
- }
- public function searchShop($key,$sell,$price,$isnew,$p) {
-
- $order=""; //排序
- $where="status=1 and name like '%{$key}%' ";
- if($isnew){
- //获取今天开始结束时间
- $dayStart=strtotime(date('Y-m-d',strtotime('-2 day')));
- $dayEnd=strtotime(date("Y-m-d 23:59:59"));
- $where.="and addtime >={$dayStart} and addtime<={$dayEnd}";
- }
- if($sell!=''){
- $order.="sale_nums {$sell},";
- }else if($price!=''){
- $order.="low_price {$price},";
- }
-
-
- $order.="id desc";
- $list=\App\handleGoodsList($where,$p,$order);
- foreach ($list as $k => $v) {
- unset($list[$k]['specs']);
- }
- return $list;
- }
- //获取本周内累计观众人数前20名的主播榜单
- public function getWeekShowLists(){
- $nowtime=time();
- $w=date('w',$nowtime);
- //获取本周开始日期,如果$w是0,则表示周日,减去 6 天
- $first=1;
- //周一
- $week=date('Y-m-d H:i:s',strtotime( date("Ymd")."-".($w ? $w - $first : 6).' days'));
- $week_start=strtotime( date("Ymd")."-".($w ? $w - $first : 6).' days');
- //本周结束日期
- //周天
- $week_end=strtotime("{$week} +1 week");
- $list_week=\PhalApi\DI()->notorm->user_liverecord
- ->select("uid,sum(nums) as total")
- ->where("starttime >={$week_start} and starttime < {$week_end} ")
- ->group("uid")
- ->order("total desc,uid asc")
- ->limit(20)
- ->fetchAll();
- foreach ($list_week as $k => $v) {
- $userinfo=\App\getUserInfo($v['uid']);
- $v['user_nickname']=$userinfo['user_nickname'];
- $v['avatar']=$userinfo['avatar'];
- $v['total']=\App\NumberFormat($v['total']);
- //判断用户是否在直播
- $live_info=\App\getLiveInfo($v['uid']);
- $v['stream']=$live_info['stream'];
- $v['islive']=$live_info['islive'];
- $list_week[$k]=$v;
- }
- return $list_week;
- }
- }
|