DataView.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. if($this->admin('is_sub')){
  27. $map['s_id']=$this->admin('id');
  28. }
  29. $order_count= MobileOrder::filterSaled()->where($map)->count();
  30. $sale_amount=MobileOrder::filterSaled()->where($map)->sum('amount');
  31. $sale_profit=MobileOrder::filterSaled()->where($map)->sum('amount_profit');
  32. return view('',compact('order_count','sale_amount','sale_profit'));
  33. }
  34. public function proxy_data(){
  35. if ($this->request->isAjax()) {
  36. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  37. $list = (new Admin)
  38. ->where($where)
  39. ->where('proxy',1)
  40. ->field(['password', 'salt', 'token'], true)
  41. ->order($sort, $order)
  42. ->paginate($limit);
  43. foreach ($list as $k => &$v) {
  44. $v['mobile_count']=$v->mobile()->count();
  45. $v['mobile_saled_count']=$v->mobile()->filterSaled()->count();
  46. }
  47. unset($v);
  48. $result = array("total" => $list->total(), "rows" => $list->items());
  49. return json($result);
  50. }
  51. return $this->view->fetch();
  52. }
  53. public function sub_data(){
  54. if ($this->request->isAjax()) {
  55. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  56. $list = (new Admin)
  57. ->where($where)
  58. ->where('sub',1)
  59. ->field(['password', 'salt', 'token'], true)
  60. ->order($sort, $order)
  61. ->paginate($limit);
  62. foreach ($list as $k => &$v) {
  63. $v['order_count']=$v->subOrder()->count();
  64. $v['sell_amount']=$v->subOrder()->filterSaled()->sum('amount');
  65. $v['profit_amount']=$v->subOrder()->filterSaled()->sum('amount_profit');
  66. }
  67. unset($v);
  68. $result = array("total" => $list->total(), "rows" => $list->items());
  69. return json($result);
  70. }
  71. return $this->view->fetch();
  72. }
  73. }