StatisticsModel.class.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <?php
  2. /**
  3. * lionfish 商城系统
  4. *
  5. * ==========================================================================
  6. * @link http://www.liofis.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license http://www.liofis.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Admin\Model;
  15. class StatisticsModel{
  16. function show_visitors_ip($date=''){
  17. $sql='SELECT * FROM '.C('DB_PREFIX').'visitors_ip';
  18. if(!empty($date)){
  19. $sql.=" where last_visit_time='".$date."'";
  20. }
  21. $count=count(M()->query($sql));
  22. $Page = new \Think\Page($count,C('BACK_PAGE_NUM'));
  23. $show = $Page->show();// 分页显示输出
  24. $sql.=' order by vi_id desc LIMIT '.$Page->firstRow.','.$Page->listRows;
  25. $list=M()->query($sql);
  26. return array(
  27. 'count'=>$count,
  28. 'empty'=>'<tr><td colspan="20">~~暂无数据</td></tr>',
  29. 'list'=>$list,
  30. 'page'=>$show
  31. );
  32. }
  33. //取得所有访问IP量
  34. function get_all_visitors_ip(){
  35. return M()->query('SELECT DISTINCT ip from '.C('DB_PREFIX').'visitors_ip');
  36. }
  37. //取某一天访问IP量
  38. function get_visitors_ip_by_date($date){
  39. return M()->query("SELECT DISTINCT ip from ".C('DB_PREFIX')."visitors_ip where last_visit_time='".$date."'");
  40. }
  41. //取得所有会员资料
  42. function get_all_member(){
  43. return M('member')->select();
  44. }
  45. function get_all_member_count(){
  46. $sql = "SELECT count(member_id) AS total FROM " . C('DB_PREFIX') . "member ";
  47. $total=M()->query($sql);
  48. return $total[0]['total'];
  49. //return M('member')->count();
  50. }
  51. //今日注册会员
  52. function get_today_register_member(){
  53. //时间大于零点时间戳
  54. return M()->query("SELECT * from ".C('DB_PREFIX')."member where create_time>=".strtotime(date('Y-m-d')));
  55. }
  56. public function get_seller_sales($data=array())
  57. {
  58. }
  59. public function get_total_sales($data=array()) {
  60. $sql = "SELECT SUM(o.total) AS total FROM " . C('DB_PREFIX') . "order as o," . C('DB_PREFIX') . "order_goods as og WHERE o.order_id=og.order_id and o.order_status_id IN (1,2,4,6,11)";
  61. if (!empty($data['date_added'])) {
  62. $sql .= " AND o.date_added>=".strtotime(date($data['date_added']))." AND o.date_added<=".(strtotime(date($data['date_added']))+86400);
  63. }
  64. if(isset($data['store_id']) && !empty($data['store_id']) )
  65. {
  66. $sql .= " and og.store_id = ".intval($data['store_id']);
  67. }
  68. $total=M()->query($sql);
  69. $sale_total=$total[0]['total'];
  70. if($sale_total){
  71. if ($sale_total > 1000000000000) {
  72. $data = round($sale_total / 1000000000000, 1) . 'T';
  73. } elseif ($sale_total > 1000000000) {
  74. $data = round($sale_total / 1000000000, 1) . 'B';
  75. } elseif ($sale_total > 1000000) {
  76. $data = round($sale_total / 1000000, 1) . 'M';
  77. } elseif ($sale_total > 1000) {
  78. $data = round($sale_total / 1000, 1) . 'K';
  79. } else {
  80. $data = round($sale_total,2);
  81. }
  82. }else{
  83. return 0;
  84. }
  85. return $data;
  86. }
  87. public function get_total_order($data=array()) {
  88. $sql = "SELECT count(*) AS total FROM " . C('DB_PREFIX') . "order as o," . C('DB_PREFIX') . "order_goods as og where o.order_id=og.order_id ";
  89. if(isset($data['store_id']) && !empty($data['store_id']) )
  90. {
  91. $sql .= " and og.store_id = ".intval($data['store_id']);
  92. }
  93. if (!empty($data['date_added'])) {
  94. $sql .= " and o.date_added>=".strtotime(date($data['date_added']))." AND o.date_added<=".(strtotime(date($data['date_added']))+86400);
  95. }
  96. $total=M()->query($sql);
  97. return $total[0]['total'];
  98. }
  99. function get_user_action(){
  100. return M('user_action')->order('ua_id desc')->limit(C('BACK_PAGE_NUM'))->select();
  101. }
  102. }
  103. ?>