php計劃任務方法

來源:互聯網
上載者:User

標籤:php計劃任務方法

          //計劃任務批量重新整理房源        public function allRefresh(){              $houseDb=D("House");              $data=$houseDb->get_list();              //dump($data);            }     下面的為model裡的資料處理,上面的為控制器部分       //查詢所有資料        public function getAll($where,$page = 1,$page_num = 10){            $houseDb=D("House");            $data=$this->where($where)->limit(($page - 1) * $page_num,$page_num)->select();            return $data;        }        //查詢所有資料總數        public function get_list(){            $where[‘isDel‘] = ‘0‘;            $where[‘status‘] = ‘2‘;            $where[‘auditstatus‘] = ‘1‘;//已審核            $where[‘salestatus‘] = ‘0‘;//在售            $houseDb=D("House");            $totalCount=$houseDb->where($where)->count();                        $totalpage=ceil($totalCount/10);            for ($nowPage=1;$nowPage<=$totalpage;$nowPage++){                $list=$houseDb->getAll($where,$nowPage,10);             //  print_r($houseDb->getLastSql()) ;                $this->refreshData($list);            }                    }        //批量重新整理房源的停留時間和計算        public function refreshData($list){           // echo ‘111‘;                foreach($list as $key=>$value){                    //計算出來停留時間                    $data=array();                    $where[‘esfId‘]=$value[‘esfId‘];                    $data[‘stayTime‘]=($value[‘publishScore‘]*$value[‘houseRatio‘])/100*3600+$value[‘verifyTime‘];                    $houseRatio=  $this->where($where)->save($data);//更新房源係數                    //首頁排序數量                    $data=array();                    $where=array();                    //計算上周經濟人日均發房源數量                    $map[‘esfId‘]=$value[‘esfId‘];                    $start=  mktime(0,0,0,date(‘m‘),date(‘d‘)-date(‘w‘)+1-7,date(‘Y‘));  //上周起時間                    $end=  mktime(23,59,59,date(‘m‘),date(‘d‘)-date(‘w‘)+7-7,date(‘Y‘));  //上周結束時間                    $map[‘verifyTime‘]=array(between,array($start,$end));                    $count=  $this->where($map)->count();//得到上周總發房源總數                    $where=array();                    $data=array();                    $where[‘esfId‘]=$value[‘esfId‘];                    if($count){                        $indexNum=$count/6; //日均發房源數量                    }                    $data[‘indexNum‘]=intval($indexNum); //日均數量                    $stayTime=$this->where($where)->save($data);//更新房源停留時間                    //echo $this->getLastSql();die;                }        }

本文出自 “PHP/[email protected]” 部落格,請務必保留此出處http://liang3391.blog.51cto.com/178205/1843760

php計劃任務方法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.