OrderUrl.php 1018 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Support\Facades\DB;
  4. class OrderUrl extends BaseModel
  5. {
  6. protected $table="orderurl";
  7. public $timestamps = false;
  8. //按投注平台获取投注数
  9. function getUrlBet(){
  10. // $data=DB::table($this->table)->select(DB::raw('count(id) count'))->groupBy('url')->
  11. $time1=date('Y-m-d 00:00:00');//今日0时
  12. $time2=date('Y-m-d 23:59:59');//
  13. $timearea=[$time1,$time2];
  14. // $timearea=['2017-10-18 00:00:00','2017-10-18 23:59:59'];//测试数据
  15. $data=$this->select(DB::raw('count(id) as value,url as name'))->whereBetween('add_time',$timearea)->groupBy('url')->get();
  16. if(!$data){
  17. return array();//没有数据
  18. }
  19. return $data->toArray();
  20. }
  21. //总数今日
  22. function gettotal(){
  23. $time1=date('Y-m-d 00:00:00');//今日0时
  24. $time2=date('Y-m-d 23:59:59');//
  25. $timearea=[$time1,$time2];
  26. return $this->whereBetween('add_time',$timearea)->count();
  27. }
  28. }