123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
- namespace app\admin\controller;
- use app\admin\model\Admin;
- use app\admin\model\AuthGroup;
- use app\admin\model\AuthGroupAccess;
- use app\common\controller\Backend;
- use app\common\model\MobileOrder;
- /**
- *
- *
- * @icon fa fa-mobile
- */
- class DataView extends Backend
- {
- public function mobile_data(){
- $noCount=\app\common\model\Mobile::group('status')->column('count(*)','status');
- return view('',compact('noCount'));
- }
- public function order_data(){
- $timerange=input('timerange');
- $map=[];
- if($timerange){
- list($stime,$etime)=explode(' - ',$timerange);
- $map['create_time']=['BETWEEN',[strtotime($stime),strtotime($etime)]];
- }
- if($this->admin('is_sub')){
- $map['s_id']=$this->admin('id');
- }
- $order_count= MobileOrder::filterSaled()->where($map)->count();
- $sale_amount=MobileOrder::filterSaled()->where($map)->sum('amount');
- $sale_profit=MobileOrder::filterSaled()->where($map)->sum('amount_profit');
- return view('',compact('order_count','sale_amount','sale_profit'));
- }
- public function proxy_data(){
- if ($this->request->isAjax()) {
- list($where, $sort, $order, $offset, $limit) = $this->buildparams();
- $list = (new Admin)
- ->where($where)
- ->where('proxy',1)
- ->field(['password', 'salt', 'token'], true)
- ->order($sort, $order)
- ->paginate($limit);
- foreach ($list as $k => &$v) {
- $v['mobile_count']=$v->mobile()->count();
- $v['mobile_saled_count']=$v->mobile()->filterSaled()->count();
- }
- unset($v);
- $result = array("total" => $list->total(), "rows" => $list->items());
- return json($result);
- }
- return $this->view->fetch();
- }
- public function sub_data(){
- if ($this->request->isAjax()) {
- list($where, $sort, $order, $offset, $limit) = $this->buildparams();
- $list = (new Admin)
- ->where($where)
- ->where('sub',1)
- ->field(['password', 'salt', 'token'], true)
- ->order($sort, $order)
- ->paginate($limit);
- foreach ($list as $k => &$v) {
- $v['order_count']=$v->subOrder()->count();
- $v['sell_amount']=$v->subOrder()->filterSaled()->sum('amount');
- $v['profit_amount']=$v->subOrder()->filterSaled()->sum('amount_profit');
- }
- unset($v);
- $result = array("total" => $list->total(), "rows" => $list->items());
- return json($result);
- }
- return $this->view->fetch();
- }
- }
|