DataView.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\model\Admin;
  4. use app\admin\model\AuthGroup;
  5. use app\admin\model\AuthGroupAccess;
  6. use app\common\controller\Backend;
  7. use app\common\model\MobileOrder;
  8. /**
  9. *
  10. *
  11. * @icon fa fa-mobile
  12. */
  13. class DataView extends Backend
  14. {
  15. public function mobile_data(){
  16. $noCount=\app\common\model\Mobile::group('status')->column('count(*)','status');
  17. return view('',compact('noCount'));
  18. }
  19. public function order_data(){
  20. $timerange=input('timerange');
  21. $map=[];
  22. if($timerange){
  23. list($stime,$etime)=explode(' - ',$timerange);
  24. $map['create_time']=['BETWEEN',[strtotime($stime),strtotime($etime)]];
  25. }
  26. $order_count= MobileOrder::where($map)->count();
  27. $sale_amount=MobileOrder::filterSaled()->where($map)->sum('amount');
  28. $sale_profit=MobileOrder::filterSaled()->where($map)->sum('amount_profit');
  29. return view('',compact('order_count','sale_amount','sale_profit'));
  30. }
  31. public function proxy_data(){
  32. if ($this->request->isAjax()) {
  33. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  34. $list = (new Admin)
  35. ->where($where)
  36. ->where('proxy',1)
  37. ->field(['password', 'salt', 'token'], true)
  38. ->order($sort, $order)
  39. ->paginate($limit);
  40. foreach ($list as $k => &$v) {
  41. $v['mobile_count']=$v->mobile()->count();
  42. $v['mobile_saled_count']=$v->mobile()->filterSaled()->count();
  43. }
  44. unset($v);
  45. $result = array("total" => $list->total(), "rows" => $list->items());
  46. return json($result);
  47. }
  48. return $this->view->fetch();
  49. }
  50. public function sub_data(){
  51. if ($this->request->isAjax()) {
  52. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  53. $list = (new Admin)
  54. ->where($where)
  55. ->where('sub',1)
  56. ->field(['password', 'salt', 'token'], true)
  57. ->order($sort, $order)
  58. ->paginate($limit);
  59. foreach ($list as $k => &$v) {
  60. $v['order_count']=$v->subOrder()->count();
  61. $v['sell_amount']=$v->subOrder()->filterSaled()->sum('amount');
  62. $v['profit_amount']=$v->subOrder()->filterSaled()->sum('amount_profit');
  63. }
  64. unset($v);
  65. $result = array("total" => $list->total(), "rows" => $list->items());
  66. return json($result);
  67. }
  68. return $this->view->fetch();
  69. }
  70. }