diff --git a/Application/Admin/Controller/SpendController.class.php b/Application/Admin/Controller/SpendController.class.php index fe443906c..4a4a84e8c 100644 --- a/Application/Admin/Controller/SpendController.class.php +++ b/Application/Admin/Controller/SpendController.class.php @@ -1,120 +1,112 @@ */ -class SpendController extends ThinkController { - const model_name = 'Spend'; - public function lists(){ - if(isset($_REQUEST['user_account'])){ - $map['tab_spend.user_account']=array('like','%'.trim($_REQUEST['user_account']).'%'); - unset($_REQUEST['user_account']); - } - if(isset($_REQUEST['spend_ip'])){ - $map['tab_spend.spend_ip']=array('like','%'.trim($_REQUEST['spend_ip']).'%'); - unset($_REQUEST['spend_ip']); - } - if(isset($_REQUEST['time-start'])&&isset($_REQUEST['time-end'])){ - $map['tab_spend.pay_time'] =array('BETWEEN',array(strtotime($_REQUEST['time-start']),strtotime($_REQUEST['time-end'])+24*60*60-1)); - unset($_REQUEST['time-start']);unset($_REQUEST['time-end']); - }elseif(isset($_REQUEST['time-start'])){ - $map['tab_spend.pay_time'] = ['GT',strtotime(I('time-start'))]; - unset($_REQUEST['time-start']); - }elseif(isset($_REQUEST['time-end'])){ - $map['tab_spend.pay_time'] = ['LT',strtotime(I('time-end'))+86399]; - unset($_REQUEST['time-end']); +class SpendController extends ThinkController +{ + const model_name = 'Spend'; + + public function lists() + { + $startDate = empty($_REQUEST['time-start']) ? date('Y-m-d', strtotime('-6 day', time())) : $_REQUEST['time-start']; + $endDate = empty($_REQUEST['time-end']) ? date('Y-m-d') : $_REQUEST['time-end']; + $startTime = strtotime($startDate); + $endTime = strtotime($endDate) + 86399; + $map['pay_time'] = array('BETWEEN', array($startTime, $endTime)); + unset($_REQUEST['time-start']); + unset($_REQUEST['time-end']); + if (isset($_REQUEST['user_account'])) { + $map['user_account'] = array('like', trim($_REQUEST['user_account'])); + unset($_REQUEST['user_account']); } - if(isset($_REQUEST['start'])&&isset($_REQUEST['end'])){ - $map['tab_spend.pay_time'] =array('BETWEEN',array(strtotime($_REQUEST['start']),strtotime($_REQUEST['end'])+24*60*60-1)); - unset($_REQUEST['start']);unset($_REQUEST['end']); - }elseif(isset($_REQUEST['start'])){ - $map['tab_spend.pay_time'] = ['GT',strtotime(I('start'))]; - unset($_REQUEST['start']); - }elseif(isset($_REQUEST['end'])){ - $map['tab_spend.pay_time'] = ['LT',strtotime(I('end'))+86399]; - unset($_REQUEST['end']); + if (isset($_REQUEST['spend_ip'])) { + $map['spend_ip'] = array('like', trim($_REQUEST['spend_ip']) . '%'); + unset($_REQUEST['spend_ip']); } - if(isset($_REQUEST['game_name'])){ - if($_REQUEST['game_name']=='全部'){ + if (isset($_REQUEST['game_name'])) { + if ($_REQUEST['game_name'] == '全部') { + unset($_REQUEST['game_name']); + } else { + $map['game_id'] = ['in', array_column(getGameByName($_REQUEST['game_name'], $_REQUEST['game_type']), 'id')]; unset($_REQUEST['game_name']); - }else{ - $map['tab_spend.game_id']= ['in', array_column(getGameByName($_REQUEST['game_name'], $_REQUEST['game_type']), 'id')]; - unset($_REQUEST['game_name']); } } - if(isset($_REQUEST['server_name'])){ - $map['tab_spend.server_name']=$_REQUEST['server_name']; + if (isset($_REQUEST['server_name'])) { + $map['server_name'] = $_REQUEST['server_name']; unset($_REQUEST['server_name']); } - if(isset($_REQUEST['pay_order_number'])){ - $map['tab_spend.pay_order_number']=array('like','%'.trim($_REQUEST['pay_order_number']).'%'); - unset($_REQUEST['pay_order_number']); + if (isset($_REQUEST['pay_order_number'])) { + $map['pay_order_number'] = array('like', trim($_REQUEST['pay_order_number']) . '%'); + unset($_REQUEST['pay_order_number']); } - if(isset($_REQUEST['pay_status'])){ - $map['tab_spend.pay_status']=$_REQUEST['pay_status']; + if (isset($_REQUEST['pay_status'])) { + $map['pay_status'] = $_REQUEST['pay_status']; unset($_REQUEST['pay_status']); } - if(isset($_REQUEST['pay_way'])){ - if($_REQUEST['pay_way']==2){ - $map['tab_spend.pay_way']=['in','2,3,4']; - }else{ - $map['tab_spend.pay_way']=$_REQUEST['pay_way']; + if (isset($_REQUEST['pay_way'])) { + if ($_REQUEST['pay_way'] == 2) { + $map['pay_way'] = ['in', '2,3,4']; + } else { + $map['pay_way'] = $_REQUEST['pay_way']; } unset($_REQUEST['pay_way']); } - if(isset($_REQUEST['pay_game_status'])){ - $map['tab_spend.pay_game_status']=$_REQUEST['pay_game_status']; + if (isset($_REQUEST['pay_game_status'])) { + $map['pay_game_status'] = $_REQUEST['pay_game_status']; unset($_REQUEST['pay_game_status']); } - if(isset($_REQUEST['promote_id'])) { - if ($_REQUEST['promote_id'] == 0) { + if (isset($_REQUEST['promote_id'])) { + $promoteId = intval($_REQUEST['promote_id']); + if ($promoteId == 0) { $map['promote_id'] = 0; } else { - $map['_complex'] = ['tp.chain'=>['like', "%/{$_REQUEST['promote_id']}/%"], 'tp.id'=>$_REQUEST['promote_id'], '_logic' => 'or']; + $promoteMap['chain'] = ['like', "%/$promoteId/%"]; + $promoteIds = M('Promote', 'tab_')->where($promoteMap)->getField('id', true); + $promoteIds[] = $promoteId; + $map['promote_id'] = ['in', $promoteIds]; } - $tab_promote_join = "left join tab_promote as tp on tp.id = tab_spend.promote_id"; - //unset($_REQUEST['promote_id']); - } else { - $tab_promote_join = false; } - - if($_REQUEST['data_order']!=''){ - $data_order=reset(explode(',',$_REQUEST['data_order'])); - $data_order_type=end(explode(',',$_REQUEST['data_order'])); - $this->assign('userarpu_order',$data_order); - $this->assign('userarpu_order_type',$data_order_type); - $sort = $data_order==3?'desc':'asc'; - $order = $data_order_type.' '.$sort; + if ($_REQUEST['data_order'] != '') { + $data_order = reset(explode(',', $_REQUEST['data_order'])); + $data_order_type = end(explode(',', $_REQUEST['data_order'])); + $this->assign('userarpu_order', $data_order); + $this->assign('userarpu_order_type', $data_order_type); + $sort = $data_order == 3 ? 'desc' : 'asc'; + $order = $data_order_type . ' ' . $sort; } else { $order = ' pay_time desc '; } - $map1=$map; - $map1['pay_status']=1; - $total=null_to_0(D(self::model_name)->where($map1)->join($tab_promote_join)->sum('pay_amount')); - $ttotal=null_to_0(D(self::model_name)->where('pay_time'.total(1))->where(array('pay_status'=>1))->join($tab_promote_join)->sum('pay_amount')); - $ytotal=null_to_0(D(self::model_name)->where('pay_time'.total(5))->where(array('pay_status'=>1))->join($tab_promote_join)->sum('pay_amount')); - $this->assign('total',$total); - $this->assign('ttotal',$ttotal); - $this->assign('ytotal',$ytotal); + if (intval(($endTime + 1) - $startTime) / (24 * 3600) <= 31) { + $map1 = $map; + $map1['pay_status'] = 1; + } else { + $map = '1 = 2'; + $map1 = $map; + } + $total = null_to_0(D(self::model_name)->where($map1)->sum('pay_amount')); + $ttotal = null_to_0(D(self::model_name)->where('pay_time' . total(1))->where(array('pay_status' => 1))->sum('pay_amount')); + $ytotal = null_to_0(D(self::model_name)->where('pay_time' . total(5))->where(array('pay_status' => 1))->sum('pay_amount')); + $this->assign('total', $total); + $this->assign('ttotal', $ttotal); + $this->assign('ytotal', $ytotal); $this->meta_title = $this->m_title = '游戏充值'; - $this->assign('commonset',M('Kuaijieicon')->where(['url'=>'Spend/lists','status'=>1])->find()); - + $this->assign('commonset', M('Kuaijieicon')->where(['url' => 'Spend/lists', 'status' => 1])->find()); - /*parent::lists(self::model_name,$_GET["p"],$map);*/ - - $data = D(self::model_name)->lists($_GET["p"], $map, $order); - - - $this->assign('list_data',$data['data']); - $this->assign('_page',$data['page']); + $data = D(self::model_name)->lists($_GET["p"], $map, $order); + $this->assign('startDate', $startDate); + $this->assign('endDate', $endDate); + $this->assign('list_data', $data['data']); + $this->assign('_page', $data['page']); $this->display(); } - + } diff --git a/Application/Admin/Controller/access_data_foldline.txt b/Application/Admin/Controller/access_data_foldline.txt index f2bc7fb38..9c7c0eeec 100644 --- a/Application/Admin/Controller/access_data_foldline.txt +++ b/Application/Admin/Controller/access_data_foldline.txt @@ -1 +1 @@ -{"news":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":0},{"time":"11:00","count":0},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":0},{"time":"15:00","count":0},{"time":"16:00","count":0},{"time":"17:00","count":0},{"time":"18:00","count":0},{"time":"19:00","count":0},{"time":"20:00","count":0},{"time":"21:00","count":0},{"time":"22:00","count":0},{"time":"23:00","count":0}],"sum":{"news":0,"active":0,"player":0,"money":0},"active":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":0},{"time":"11:00","count":0},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":0},{"time":"15:00","count":0},{"time":"16:00","count":0},{"time":"17:00","count":0},{"time":"18:00","count":0},{"time":"19:00","count":0},{"time":"20:00","count":0},{"time":"21:00","count":0},{"time":"22:00","count":0},{"time":"23:00","count":0}],"player":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":0},{"time":"11:00","count":0},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":0},{"time":"15:00","count":0},{"time":"16:00","count":0},{"time":"17:00","count":0},{"time":"18:00","count":0},{"time":"19:00","count":0},{"time":"20:00","count":0},{"time":"21:00","count":0},{"time":"22:00","count":0},{"time":"23:00","count":0}],"money":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":0},{"time":"11:00","count":0},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":0},{"time":"15:00","count":0},{"time":"16:00","count":0},{"time":"17:00","count":0},{"time":"18:00","count":0},{"time":"19:00","count":0},{"time":"20:00","count":0},{"time":"21:00","count":0},{"time":"22:00","count":0},{"time":"23:00","count":0}]} \ No newline at end of file +{"news":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":3},{"time":"11:00","count":1},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":0},{"time":"15:00","count":2},{"time":"16:00","count":0},{"time":"17:00","count":0},{"time":"18:00","count":1},{"time":"19:00","count":0},{"time":"20:00","count":0},{"time":"21:00","count":0},{"time":"22:00","count":0},{"time":"23:00","count":0}],"sum":{"news":7,"active":17,"player":3,"money":0.080000000000000002},"active":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":4},{"time":"10:00","count":6},{"time":"11:00","count":1},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":0},{"time":"15:00","count":4},{"time":"16:00","count":0},{"time":"17:00","count":0},{"time":"18:00","count":2},{"time":"19:00","count":0},{"time":"20:00","count":0},{"time":"21:00","count":0},{"time":"22:00","count":0},{"time":"23:00","count":0}],"player":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":0},{"time":"11:00","count":0},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":0},{"time":"15:00","count":1},{"time":"16:00","count":2},{"time":"17:00","count":0},{"time":"18:00","count":0},{"time":"19:00","count":0},{"time":"20:00","count":0},{"time":"21:00","count":0},{"time":"22:00","count":0},{"time":"23:00","count":0}],"money":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":0},{"time":"11:00","count":0},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":0},{"time":"15:00","count":"0.04"},{"time":"16:00","count":"0.04"},{"time":"17:00","count":0},{"time":"18:00","count":0},{"time":"19:00","count":0},{"time":"20:00","count":0},{"time":"21:00","count":0},{"time":"22:00","count":0},{"time":"23:00","count":0}]} \ No newline at end of file diff --git a/Application/Admin/Controller/device_data_foldline.txt b/Application/Admin/Controller/device_data_foldline.txt index 3506b5f47..480ca25d3 100644 --- a/Application/Admin/Controller/device_data_foldline.txt +++ b/Application/Admin/Controller/device_data_foldline.txt @@ -1 +1 @@ -{"average":{"news":0,"active":0},"sum":{"news":0,"active":0},"news":[{"time":"2019-10-30 00:00","count":0,"version":"ios"},{"time":"2019-10-30 01:00","count":0,"version":"ios"},{"time":"2019-10-30 02:00","count":0,"version":"ios"},{"time":"2019-10-30 03:00","count":0,"version":"ios"},{"time":"2019-10-30 04:00","count":0,"version":"ios"},{"time":"2019-10-30 05:00","count":0,"version":"ios"},{"time":"2019-10-30 06:00","count":0,"version":"ios"},{"time":"2019-10-30 07:00","count":0,"version":"ios"},{"time":"2019-10-30 08:00","count":0,"version":"ios"},{"time":"2019-10-30 09:00","count":0,"version":"ios"},{"time":"2019-10-30 10:00","count":0,"version":"ios"},{"time":"2019-10-30 11:00","count":0,"version":"ios"},{"time":"2019-10-30 12:00","count":0,"version":"ios"},{"time":"2019-10-30 13:00","count":0,"version":"ios"},{"time":"2019-10-30 14:00","count":0,"version":"ios"},{"time":"2019-10-30 15:00","count":0,"version":"ios"},{"time":"2019-10-30 16:00","count":0,"version":"ios"},{"time":"2019-10-30 17:00","count":0,"version":"ios"},{"time":"2019-10-30 18:00","count":0,"version":"ios"},{"time":"2019-10-30 19:00","count":0,"version":"ios"},{"time":"2019-10-30 20:00","count":0,"version":"ios"},{"time":"2019-10-30 21:00","count":0,"version":"ios"},{"time":"2019-10-30 22:00","count":0,"version":"ios"},{"time":"2019-10-30 23:00","count":0,"version":"ios"},{"time":"2019-10-30 00:00","count":0,"version":"android"},{"time":"2019-10-30 01:00","count":0,"version":"android"},{"time":"2019-10-30 02:00","count":0,"version":"android"},{"time":"2019-10-30 03:00","count":0,"version":"android"},{"time":"2019-10-30 04:00","count":0,"version":"android"},{"time":"2019-10-30 05:00","count":0,"version":"android"},{"time":"2019-10-30 06:00","count":0,"version":"android"},{"time":"2019-10-30 07:00","count":0,"version":"android"},{"time":"2019-10-30 08:00","count":0,"version":"android"},{"time":"2019-10-30 09:00","count":0,"version":"android"},{"time":"2019-10-30 10:00","count":0,"version":"android"},{"time":"2019-10-30 11:00","count":0,"version":"android"},{"time":"2019-10-30 12:00","count":0,"version":"android"},{"time":"2019-10-30 13:00","count":0,"version":"android"},{"time":"2019-10-30 14:00","count":0,"version":"android"},{"time":"2019-10-30 15:00","count":0,"version":"android"},{"time":"2019-10-30 16:00","count":0,"version":"android"},{"time":"2019-10-30 17:00","count":0,"version":"android"},{"time":"2019-10-30 18:00","count":0,"version":"android"},{"time":"2019-10-30 19:00","count":0,"version":"android"},{"time":"2019-10-30 20:00","count":0,"version":"android"},{"time":"2019-10-30 21:00","count":0,"version":"android"},{"time":"2019-10-30 22:00","count":0,"version":"android"},{"time":"2019-10-30 23:00","count":0,"version":"android"}],"active":[{"time":"2019-10-30 00:00","count":0,"version":"ios"},{"time":"2019-10-30 01:00","count":0,"version":"ios"},{"time":"2019-10-30 02:00","count":0,"version":"ios"},{"time":"2019-10-30 03:00","count":0,"version":"ios"},{"time":"2019-10-30 04:00","count":0,"version":"ios"},{"time":"2019-10-30 05:00","count":0,"version":"ios"},{"time":"2019-10-30 06:00","count":0,"version":"ios"},{"time":"2019-10-30 07:00","count":0,"version":"ios"},{"time":"2019-10-30 08:00","count":0,"version":"ios"},{"time":"2019-10-30 09:00","count":0,"version":"ios"},{"time":"2019-10-30 10:00","count":0,"version":"ios"},{"time":"2019-10-30 11:00","count":0,"version":"ios"},{"time":"2019-10-30 12:00","count":0,"version":"ios"},{"time":"2019-10-30 13:00","count":0,"version":"ios"},{"time":"2019-10-30 14:00","count":0,"version":"ios"},{"time":"2019-10-30 15:00","count":0,"version":"ios"},{"time":"2019-10-30 16:00","count":0,"version":"ios"},{"time":"2019-10-30 17:00","count":0,"version":"ios"},{"time":"2019-10-30 18:00","count":0,"version":"ios"},{"time":"2019-10-30 19:00","count":0,"version":"ios"},{"time":"2019-10-30 20:00","count":0,"version":"ios"},{"time":"2019-10-30 21:00","count":0,"version":"ios"},{"time":"2019-10-30 22:00","count":0,"version":"ios"},{"time":"2019-10-30 23:00","count":0,"version":"ios"},{"time":"2019-10-30 00:00","count":0,"version":"android"},{"time":"2019-10-30 01:00","count":0,"version":"android"},{"time":"2019-10-30 02:00","count":0,"version":"android"},{"time":"2019-10-30 03:00","count":0,"version":"android"},{"time":"2019-10-30 04:00","count":0,"version":"android"},{"time":"2019-10-30 05:00","count":0,"version":"android"},{"time":"2019-10-30 06:00","count":0,"version":"android"},{"time":"2019-10-30 07:00","count":0,"version":"android"},{"time":"2019-10-30 08:00","count":0,"version":"android"},{"time":"2019-10-30 09:00","count":0,"version":"android"},{"time":"2019-10-30 10:00","count":0,"version":"android"},{"time":"2019-10-30 11:00","count":0,"version":"android"},{"time":"2019-10-30 12:00","count":0,"version":"android"},{"time":"2019-10-30 13:00","count":0,"version":"android"},{"time":"2019-10-30 14:00","count":0,"version":"android"},{"time":"2019-10-30 15:00","count":0,"version":"android"},{"time":"2019-10-30 16:00","count":0,"version":"android"},{"time":"2019-10-30 17:00","count":0,"version":"android"},{"time":"2019-10-30 18:00","count":0,"version":"android"},{"time":"2019-10-30 19:00","count":0,"version":"android"},{"time":"2019-10-30 20:00","count":0,"version":"android"},{"time":"2019-10-30 21:00","count":0,"version":"android"},{"time":"2019-10-30 22:00","count":0,"version":"android"},{"time":"2019-10-30 23:00","count":0,"version":"android"}]} \ No newline at end of file +{"average":{"news":0,"active":0},"sum":{"news":0,"active":0},"news":[{"time":"2019-11-11 00:00","count":0,"version":"ios"},{"time":"2019-11-11 01:00","count":0,"version":"ios"},{"time":"2019-11-11 02:00","count":0,"version":"ios"},{"time":"2019-11-11 03:00","count":0,"version":"ios"},{"time":"2019-11-11 04:00","count":0,"version":"ios"},{"time":"2019-11-11 05:00","count":0,"version":"ios"},{"time":"2019-11-11 06:00","count":0,"version":"ios"},{"time":"2019-11-11 07:00","count":0,"version":"ios"},{"time":"2019-11-11 08:00","count":0,"version":"ios"},{"time":"2019-11-11 09:00","count":0,"version":"ios"},{"time":"2019-11-11 10:00","count":0,"version":"ios"},{"time":"2019-11-11 11:00","count":0,"version":"ios"},{"time":"2019-11-11 12:00","count":0,"version":"ios"},{"time":"2019-11-11 13:00","count":0,"version":"ios"},{"time":"2019-11-11 14:00","count":0,"version":"ios"},{"time":"2019-11-11 15:00","count":0,"version":"ios"},{"time":"2019-11-11 16:00","count":0,"version":"ios"},{"time":"2019-11-11 17:00","count":0,"version":"ios"},{"time":"2019-11-11 18:00","count":0,"version":"ios"},{"time":"2019-11-11 19:00","count":0,"version":"ios"},{"time":"2019-11-11 20:00","count":0,"version":"ios"},{"time":"2019-11-11 21:00","count":0,"version":"ios"},{"time":"2019-11-11 22:00","count":0,"version":"ios"},{"time":"2019-11-11 23:00","count":0,"version":"ios"},{"time":"2019-11-11 00:00","count":0,"version":"android"},{"time":"2019-11-11 01:00","count":0,"version":"android"},{"time":"2019-11-11 02:00","count":0,"version":"android"},{"time":"2019-11-11 03:00","count":0,"version":"android"},{"time":"2019-11-11 04:00","count":0,"version":"android"},{"time":"2019-11-11 05:00","count":0,"version":"android"},{"time":"2019-11-11 06:00","count":0,"version":"android"},{"time":"2019-11-11 07:00","count":0,"version":"android"},{"time":"2019-11-11 08:00","count":0,"version":"android"},{"time":"2019-11-11 09:00","count":0,"version":"android"},{"time":"2019-11-11 10:00","count":0,"version":"android"},{"time":"2019-11-11 11:00","count":0,"version":"android"},{"time":"2019-11-11 12:00","count":0,"version":"android"},{"time":"2019-11-11 13:00","count":0,"version":"android"},{"time":"2019-11-11 14:00","count":0,"version":"android"},{"time":"2019-11-11 15:00","count":0,"version":"android"},{"time":"2019-11-11 16:00","count":0,"version":"android"},{"time":"2019-11-11 17:00","count":0,"version":"android"},{"time":"2019-11-11 18:00","count":0,"version":"android"},{"time":"2019-11-11 19:00","count":0,"version":"android"},{"time":"2019-11-11 20:00","count":0,"version":"android"},{"time":"2019-11-11 21:00","count":0,"version":"android"},{"time":"2019-11-11 22:00","count":0,"version":"android"},{"time":"2019-11-11 23:00","count":0,"version":"android"}],"active":[{"time":"2019-11-11 00:00","count":0,"version":"ios"},{"time":"2019-11-11 01:00","count":0,"version":"ios"},{"time":"2019-11-11 02:00","count":0,"version":"ios"},{"time":"2019-11-11 03:00","count":0,"version":"ios"},{"time":"2019-11-11 04:00","count":0,"version":"ios"},{"time":"2019-11-11 05:00","count":0,"version":"ios"},{"time":"2019-11-11 06:00","count":0,"version":"ios"},{"time":"2019-11-11 07:00","count":0,"version":"ios"},{"time":"2019-11-11 08:00","count":0,"version":"ios"},{"time":"2019-11-11 09:00","count":0,"version":"ios"},{"time":"2019-11-11 10:00","count":0,"version":"ios"},{"time":"2019-11-11 11:00","count":0,"version":"ios"},{"time":"2019-11-11 12:00","count":0,"version":"ios"},{"time":"2019-11-11 13:00","count":0,"version":"ios"},{"time":"2019-11-11 14:00","count":0,"version":"ios"},{"time":"2019-11-11 15:00","count":0,"version":"ios"},{"time":"2019-11-11 16:00","count":0,"version":"ios"},{"time":"2019-11-11 17:00","count":0,"version":"ios"},{"time":"2019-11-11 18:00","count":0,"version":"ios"},{"time":"2019-11-11 19:00","count":0,"version":"ios"},{"time":"2019-11-11 20:00","count":0,"version":"ios"},{"time":"2019-11-11 21:00","count":0,"version":"ios"},{"time":"2019-11-11 22:00","count":0,"version":"ios"},{"time":"2019-11-11 23:00","count":0,"version":"ios"},{"time":"2019-11-11 00:00","count":0,"version":"android"},{"time":"2019-11-11 01:00","count":0,"version":"android"},{"time":"2019-11-11 02:00","count":0,"version":"android"},{"time":"2019-11-11 03:00","count":0,"version":"android"},{"time":"2019-11-11 04:00","count":0,"version":"android"},{"time":"2019-11-11 05:00","count":0,"version":"android"},{"time":"2019-11-11 06:00","count":0,"version":"android"},{"time":"2019-11-11 07:00","count":0,"version":"android"},{"time":"2019-11-11 08:00","count":0,"version":"android"},{"time":"2019-11-11 09:00","count":0,"version":"android"},{"time":"2019-11-11 10:00","count":0,"version":"android"},{"time":"2019-11-11 11:00","count":0,"version":"android"},{"time":"2019-11-11 12:00","count":0,"version":"android"},{"time":"2019-11-11 13:00","count":0,"version":"android"},{"time":"2019-11-11 14:00","count":0,"version":"android"},{"time":"2019-11-11 15:00","count":0,"version":"android"},{"time":"2019-11-11 16:00","count":0,"version":"android"},{"time":"2019-11-11 17:00","count":0,"version":"android"},{"time":"2019-11-11 18:00","count":0,"version":"android"},{"time":"2019-11-11 19:00","count":0,"version":"android"},{"time":"2019-11-11 20:00","count":0,"version":"android"},{"time":"2019-11-11 21:00","count":0,"version":"android"},{"time":"2019-11-11 22:00","count":0,"version":"android"},{"time":"2019-11-11 23:00","count":0,"version":"android"}]} \ No newline at end of file diff --git a/Application/Admin/Model/SpendModel.class.php b/Application/Admin/Model/SpendModel.class.php index 775981c5e..6f5e3ab07 100644 --- a/Application/Admin/Model/SpendModel.class.php +++ b/Application/Admin/Model/SpendModel.class.php @@ -8,6 +8,7 @@ // +---------------------------------------------------------------------- namespace Admin\Model; + use Common\Api\GameApi; use Org\WeixinSDK\Weixin; use Think\Model; @@ -15,8 +16,8 @@ use Think\Model; /** * 文档基础模型 */ -class SpendModel extends Model{ - +class SpendModel extends Model +{ /* 自动验证规则 */ @@ -24,16 +25,17 @@ class SpendModel extends Model{ /* 自动完成规则 */ protected $_auto = array( - array('pay_time', 'getCreateTime', self::MODEL_INSERT,'callback'), - array('pay_status', 0, self::MODEL_INSERT), - array('order_number','',self::MODEL_INSERT), + array('pay_time', 'getCreateTime', self::MODEL_INSERT, 'callback'), + array('pay_status', 0, self::MODEL_INSERT), + array('order_number', '', self::MODEL_INSERT), ); -protected function _after_select(&$result,$options){ - foreach($result as $key=>$value){ - // $result[$key]['pay_way'] = date('Y-m-d ', $value['time']); - } - } + protected function _after_select(&$result, $options) + { + foreach ($result as $key => $value) { + // $result[$key]['pay_way'] = date('Y-m-d ', $value['time']); + } + } /** * 构造函数 @@ -41,9 +43,10 @@ protected function _after_select(&$result,$options){ * @param string $tablePrefix 表前缀 * @param mixed $connection 数据库连接信息 */ - public function __construct($name = '', $tablePrefix = '', $connection = '') { + public function __construct($name = '', $tablePrefix = '', $connection = '') + { /* 设置默认的表前缀 */ - $this->tablePrefix ='tab_'; + $this->tablePrefix = 'tab_'; /* 执行构造方法 */ parent::__construct($name, $tablePrefix, $connection); } @@ -54,16 +57,19 @@ protected function _after_select(&$result,$options){ * @return int 时间戳 * @author huajie */ - protected function getCreateTime(){ - $create_time = I('post.create_time'); - return $create_time?strtotime($create_time):NOW_TIME; + protected function getCreateTime() + { + $create_time = I('post.create_time'); + return $create_time ? strtotime($create_time) : NOW_TIME; } public function amdin_account() { - return session('user_auth.username'); + return session('user_auth.username'); } - public function totalSpendTimes($map=""){ + + public function totalSpendTimes($map = "") + { $map['s.pay_status'] = 1; $data = $this->alias("s")->field("IFNULL(count(pay_amount),0) as count") ->join("left join tab_game g on g.id = s.game_id") @@ -71,40 +77,44 @@ protected function _after_select(&$result,$options){ ->find(); return $data['count']; } + /** * [dealPage 页码处理] * @param [type] $p [description] * @return [type] [description] */ - public function dealPage($p){ + public function dealPage($p) + { $page = intval($p); $page = $page ? $page : 1; //默认显示第一页数据 return $page; } + /** * 自动补单 */ - public static function auto_repair(){ + public static function auto_repair() + { $game = new GameApi(); - $map['pay_status'] = 1; + $map['pay_status'] = 1; $map['pay_game_status'] = 0; - $order = M("spend",'tab_')->field('pay_order_number,1 as code')->where($map)->select();//普通消费 - $bind_spend = M("bind_spend",'tab_')->field('pay_order_number,2 as code')->where($map)->select();//绑币消费 - if(!empty($bind_spend)){ - array_push($order,$bind_spend); + $order = M("spend", 'tab_')->field('pay_order_number,1 as code')->where($map)->select();//普通消费 + $bind_spend = M("bind_spend", 'tab_')->field('pay_order_number,2 as code')->where($map)->select();//绑币消费 + if (!empty($bind_spend)) { + array_push($order, $bind_spend); } $success_num = $error_num = 0; - foreach ($order as $key=>$val) { + foreach ($order as $key => $val) { $param['out_trade_no'] = $val['pay_order_number']; $result = $game->game_pay_notify($param, $val['code']); - if($val['code'] == 1){ - M('spend','tab_')->where(['pay_order_number'=>$val['pay_order_number']])->setInc('auto_compensation'); - }else{ - M('bind_spend','tab_')->where(['pay_order_number'=>$val['pay_order_number']])->setInc('auto_compensation'); + if ($val['code'] == 1) { + M('spend', 'tab_')->where(['pay_order_number' => $val['pay_order_number']])->setInc('auto_compensation'); + } else { + M('bind_spend', 'tab_')->where(['pay_order_number' => $val['pay_order_number']])->setInc('auto_compensation'); } - if($result == "success"){ + if ($result == "success") { $success_num++; - }else{ + } else { $error_num++; } } @@ -117,19 +127,19 @@ protected function _after_select(&$result,$options){ * 退款接口 * @param $map */ - public function Refund($map,$order,$sign) + public function Refund($map, $order, $sign) { - if(md5("mcaseqwezdsi".$order)!==$sign){ - return false; + if (md5("mcaseqwezdsi" . $order) !== $sign) { + return false; } $RefundRecord = M('RefundRecord', 'tab_')->where($map)->find(); if (null == $RefundRecord) { $find = $this->where($map)->find(); $order_number = $find['pay_way'] == 1 ? date("YmdHis") : "TK_" . date('Ymd') . date('His') . sp_random_string(4); - $BatchNo=date("YmdHis"); + $BatchNo = date("YmdHis"); } else { $order_number = $RefundRecord['order_number']; - $BatchNo=$RefundRecord['batch_no']; + $BatchNo = $RefundRecord['batch_no']; $find = $RefundRecord; } @@ -139,7 +149,7 @@ protected function _after_select(&$result,$options){ $vo = new \Think\Pay\PayVo(); $detail_data = $find['order_number'] . "^" . $find['pay_amount'] . "^调单"; - $find['batch_no']=$BatchNo; + $find['batch_no'] = $BatchNo; $vo->setOrderNo($find['order_number']) ->setService("refund_fastpay_by_platform_pwd") ->setSignType("MD5") @@ -165,7 +175,7 @@ protected function _after_select(&$result,$options){ $config = array("partner" => trim(C("weixin.partner")), "email" => "", "key" => trim(C("weixin.key"))); $pay = new \Think\Pay('swiftpass', $config); $vo = new \Think\Pay\PayVo(); - $vo->setService('unified.trade.refund') + $vo->setService('unified.trade.refund') ->setSignType("MD5") ->setPayMethod("refund") ->setTable("RefundRecord") @@ -173,8 +183,8 @@ protected function _after_select(&$result,$options){ ->setBatchNo($order_number) ->setFee($find['pay_amount']); $this->add_refund_record($find, $order_number); - $this->where($map)->delete(); - $res=$pay->buildRequestForm($vo); + $this->where($map)->delete(); + $res = $pay->buildRequestForm($vo); if ($res['status'] == 0) { return $res['status']; } else { @@ -183,8 +193,8 @@ protected function _after_select(&$result,$options){ } elseif ($find['pay_way'] == 0) { $user_map['id'] = $find['user_id']; M('user', 'tab_')->where($user_map)->setInc('balance', $find['pay_amount']); - $this->add_refund_record($find, $order_number); - $this->where($map)->delete(); + $this->add_refund_record($find, $order_number); + $this->where($map)->delete(); return true; } @@ -202,24 +212,24 @@ protected function _after_select(&$result,$options){ $map['pay_order_number'] = $data['pay_order_number']; $find = $RefundRecord->where($map)->find(); if (null !== $find) { - if($data['pay_way']==4||$data['pay_way']==3){ + if ($data['pay_way'] == 4 || $data['pay_way'] == 3) { $RefundRecord->where($map)->delete(); $data['tui_status'] = 2; $data['create_time'] = time(); $data['tui_amount'] = $data['pay_amount']; $data['order_number'] = $order_number; return $RefundRecord->add($data); - }else{ + } else { return true; } } else { if ($data['pay_way'] == 0) { $data['tui_status'] = 1; $data['tui_time'] = time(); - $savv['sub_status']=1; - $savv['settle_check']=1; + $savv['sub_status'] = 1; + $savv['settle_check'] = 1; $this->where($map)->save($savv); - }elseif($data['pay_way'] == 4||$data['pay_way']==3){ + } elseif ($data['pay_way'] == 4 || $data['pay_way'] == 3) { $data['tui_status'] = 2; } @@ -232,34 +242,33 @@ protected function _after_select(&$result,$options){ } - - /** * 微信退款查询接口 * @param [type] $orderNo [description] * @return [type] [description] */ - public function weixin_refundquery($orderNo){ - $weixn = new Weixin(); - $res = $weixn->weixin_refundquery($orderNo); - if($res=="SUCCESS"){ - M('RefundRecord', 'tab_')->where(array('pay_order_number'=>$orderNo))->setField('tui_status', 1); - return json_encode(array('status'=>1,'msg'=>'退款成功')); - }elseif($res=="FAIL"){ - return json_encode(array('status'=>0,'msg'=>'退款失败')); - }elseif($res=="PROCESSING"){ - return json_encode(array('status'=>0,'msg'=>'退款处理中')); - } + public function weixin_refundquery($orderNo) + { + $weixn = new Weixin(); + $res = $weixn->weixin_refundquery($orderNo); + if ($res == "SUCCESS") { + M('RefundRecord', 'tab_')->where(array('pay_order_number' => $orderNo))->setField('tui_status', 1); + return json_encode(array('status' => 1, 'msg' => '退款成功')); + } elseif ($res == "FAIL") { + return json_encode(array('status' => 0, 'msg' => '退款失败')); + } elseif ($res == "PROCESSING") { + return json_encode(array('status' => 0, 'msg' => '退款处理中')); + } } - /** * 威富通查询退款接口 * @param [type] $map [description] * @return [type] [description] */ - public function swiftpass_refund($orderNo){ + public function swiftpass_refund($orderNo) + { $config = array("partner" => trim(C("weixin.partner")), "email" => "", "key" => trim(C("weixin.key"))); $pay = new \Think\Pay('swiftpass', $config); $vo = new \Think\Pay\PayVo(); @@ -268,429 +277,495 @@ protected function _after_select(&$result,$options){ ->setSignType("MD5") ->setPayMethod("find") ->setTable("RefundRecord"); - $res=$pay->buildRequestForm($vo); - if($res['refund_status']=="SUCCESS"){ - M('RefundRecord', 'tab_')->where(array('pay_order_number'=>$orderNo))->setField('tui_status', 1); - return json_encode(array('status'=>1,'msg'=>'退款成功')); - }elseif($res['refund_status']=="FAIL"){ - return json_encode(array('status'=>0,'msg'=>'退款失败')); - }elseif($res['refund_status']=="PROCESSING"){ - return json_encode(array('status'=>0,'msg'=>'退款处理中')); + $res = $pay->buildRequestForm($vo); + if ($res['refund_status'] == "SUCCESS") { + M('RefundRecord', 'tab_')->where(array('pay_order_number' => $orderNo))->setField('tui_status', 1); + return json_encode(array('status' => 1, 'msg' => '退款成功')); + } elseif ($res['refund_status'] == "FAIL") { + return json_encode(array('status' => 0, 'msg' => '退款失败')); + } elseif ($res['refund_status'] == "PROCESSING") { + return json_encode(array('status' => 0, 'msg' => '退款处理中')); } } - - - - - - - - - - /** - * 开放平台 付费人数 - * @param string $map - * @return mixed - * author: xmy 280564871@qq.com - */ - public function countSpendUserOfOpen($map=""){ - $sql = $this->alias("s")->field("s.user_id") - ->join("left join tab_game g on g.id = s.game_id") - ->where($map) - ->group("s.game_id,s.user_id") - ->select(false); - $sql = "select count(DISTINCT user_id) as num from ({$sql}) as res"; - $data = M()->query($sql); - return $data[0]['num']; + /** + * 开放平台 付费人数 + * @param string $map + * @return mixed + * author: xmy 280564871@qq.com + */ + public function countSpendUserOfOpen($map = "") + { + $sql = $this->alias("s")->field("s.user_id") + ->join("left join tab_game g on g.id = s.game_id") + ->where($map) + ->group("s.game_id,s.user_id") + ->select(false); + $sql = "select count(DISTINCT user_id) as num from ({$sql}) as res"; + $data = M()->query($sql); + return $data[0]['num']; } - /** - * 累计付费 - * @param string $map - * @return mixed - * author: xmy 280564871@qq.com - */ - public function totalSpend($map=""){ - $map['s.pay_status'] = 1; - $data = $this->alias("s")->field("IFNULL(sum(pay_amount),0) as num") - ->join("right join tab_game g on g.id = s.game_id") - ->where($map) - ->find(); - return $data['num']; + /** + * 累计付费 + * @param string $map + * @return mixed + * author: xmy 280564871@qq.com + */ + public function totalSpend($map = "") + { + $map['s.pay_status'] = 1; + $data = $this->alias("s")->field("IFNULL(sum(pay_amount),0) as num") + ->join("right join tab_game g on g.id = s.game_id") + ->where($map) + ->find(); + return $data['num']; } - /** - * 获取开放平台流水 - * @param $map - * @param $develop_id - * author: xmy 280564871@qq.com - */ - public function getOpenSpend($map,$develop_id,$game_id){ + /** + * 获取开放平台流水 + * @param $map + * @param $develop_id + * author: xmy 280564871@qq.com + */ + public function getOpenSpend($map, $develop_id, $game_id) + { // empty($game_id) || $map['s.game_id'] = $game_id; - empty($game_id) || $join = "and g.id = {$game_id}"; - $data = $this->alias("s")->field("IFNULL(sum(pay_amount),0) as num,d.time") - ->join("right join tab_game g on g.id = s.game_id and g.developers = $develop_id {$join}") - ->join("right join sys_date_list d on d.time = FROM_UNIXTIME(s.pay_time,'%Y-%m-%d') and s.pay_status = 1") - ->where($map) - ->group("d.time") - ->select(); - return $data; + empty($game_id) || $join = "and g.id = {$game_id}"; + $data = $this->alias("s")->field("IFNULL(sum(pay_amount),0) as num,d.time") + ->join("right join tab_game g on g.id = s.game_id and g.developers = $develop_id {$join}") + ->join("right join sys_date_list d on d.time = FROM_UNIXTIME(s.pay_time,'%Y-%m-%d') and s.pay_status = 1") + ->where($map) + ->group("d.time") + ->select(); + return $data; } - /** - * 付费玩家数 - * @param $map - * @param $develop_id - * @return mixed - * author: xmy 280564871@qq.com - */ - public function getPayerNum($map,$develop_id,$game_id){ + /** + * 付费玩家数 + * @param $map + * @param $develop_id + * @return mixed + * author: xmy 280564871@qq.com + */ + public function getPayerNum($map, $develop_id, $game_id) + { // empty($game_id) || $map['s.game_id'] = $game_id; - empty($game_id) || $join = "and g.id = {$game_id}"; - $data = $this->alias("s")->field("IFNULL(count(DISTINCT user_id),0) as num,d.time") - ->join("right join tab_game g on g.id = s.game_id and g.developers = $develop_id {$join}") - ->join("right join sys_date_list d on d.time = FROM_UNIXTIME(s.pay_time,'%Y-%m-%d') and s.pay_status = 1") - ->where($map) - ->group("d.time") - ->select(); - return $data; + empty($game_id) || $join = "and g.id = {$game_id}"; + $data = $this->alias("s")->field("IFNULL(count(DISTINCT user_id),0) as num,d.time") + ->join("right join tab_game g on g.id = s.game_id and g.developers = $develop_id {$join}") + ->join("right join sys_date_list d on d.time = FROM_UNIXTIME(s.pay_time,'%Y-%m-%d') and s.pay_status = 1") + ->where($map) + ->group("d.time") + ->select(); + return $data; } - /** - * 新增付费玩家 - * @param $start - * @param $end - * @param $develop_id - * @return mixed - * author: xmy 280564871@qq.com - */ - public function getNewPayerNum($start,$end,$develop_id,$game_id){ - //第一次充值 - empty($game_id) || $map['s.game_id'] = $game_id; - - $map['s.pay_status'] = 1; - $sql = $this->alias("s")->field("user_id,min(pay_time) as pay_time") - ->join("right join tab_game g on g.id = s.game_id and g.developers = $develop_id") - ->where($map) - ->group("s.user_id") - ->select(false); - $sql = "SELECT count(res.user_id) as num,d.time FROM ({$sql}) res right join sys_date_list d on d.time = FROM_UNIXTIME(res.pay_time,'%Y-%m-%d') + /** + * 新增付费玩家 + * @param $start + * @param $end + * @param $develop_id + * @return mixed + * author: xmy 280564871@qq.com + */ + public function getNewPayerNum($start, $end, $develop_id, $game_id) + { + //第一次充值 + empty($game_id) || $map['s.game_id'] = $game_id; + + $map['s.pay_status'] = 1; + $sql = $this->alias("s")->field("user_id,min(pay_time) as pay_time") + ->join("right join tab_game g on g.id = s.game_id and g.developers = $develop_id") + ->where($map) + ->group("s.user_id") + ->select(false); + $sql = "SELECT count(res.user_id) as num,d.time FROM ({$sql}) res right join sys_date_list d on d.time = FROM_UNIXTIME(res.pay_time,'%Y-%m-%d') WHERE d.time BETWEEN '{$start}' and '{$end}' GROUP BY d.time"; - $data = $this->query($sql); - return $data; + $data = $this->query($sql); + return $data; } - /** - * 累计付费玩家数(按天分组) - * @param $map - * @param $develop_id - * @return mixed - * author: xmy 280564871@qq.com - */ - public function getTotalPayerNum($start,$end,$develop_id){ - $start = strtotime($start); - $end = strtotime($end); - $map['g.developers'] = $develop_id; - $map['s.pay_status'] = 1; - for ($time = $start; $time <= $end; $time += 86400) { - $map['s.pay_time'] = ['lt',$time+86399]; - $data[]['num'] = $this->countSpendUserOfOpen($map); - } - return $data; + /** + * 累计付费玩家数(按天分组) + * @param $map + * @param $develop_id + * @return mixed + * author: xmy 280564871@qq.com + */ + public function getTotalPayerNum($start, $end, $develop_id) + { + $start = strtotime($start); + $end = strtotime($end); + $map['g.developers'] = $develop_id; + $map['s.pay_status'] = 1; + for ($time = $start; $time <= $end; $time += 86400) { + $map['s.pay_time'] = ['lt', $time + 86399]; + $data[]['num'] = $this->countSpendUserOfOpen($map); + } + return $data; } - /** - * 累计流水 - * @param $map - * @return mixed - * author: xmy 280564871@qq.com - */ - public function getTotalSpend($map){ - $map['pay_status'] = 1; - $data = $this->field("IFNULL(sum(pay_amount),0) as num")->where($map)->find(); - return $data; - } - - /* - * 游戏充值未到账列表 - * @return array 结果集 - * @author 鹿文学 - */ - public function checkSpend() { - - $list = $this->field('id,user_id,user_account,game_id,game_name,pay_amount,pay_order_number')->where(array('pay_status'=>0))->select(); - $type = 101; - if ($list[0]) { - - $list = D('check')->dealWithCheckList($type,$list); - - if (empty($list[0])) {return '';} - - foreach ($list as $k => $v) { - $data[$k]['info'] = '玩家:'.$v['user_account'].',游戏['.$v['game_name'].']充值金额:'.$v['pay_amount'].',订单状态:下单未支付'; - $data[$k]['type'] = $type; - $data[$k]['url'] = U('Spend/lists',array('pay_order_number'=>$v['pay_order_number'])); - $data[$k]['create_time'] = time(); - $data[$k]['status']=0; - $data[$k]['position'] = $v['id']; - } - return $data; - }else { - D('check')->dealWithCheckListOnNull($type); - return ''; - } - - } - - /* - * 游戏补单列表 - * @return array 结果集 - * @author 鹿文学 - */ - public function checkSupplement() { - - $list = $this->field('id,user_id,user_account,pay_order_number')->where(array('pay_status'=>1,'pay_game_status'=>0))->select(); - $type = 102; - if ($list[0]) { - - $list = D('check')->dealWithCheckList($type,$list); - - if (empty($list[0])) {return '';} - - foreach ($list as $k => $v) { - $data[$k]['info'] = '玩家:'.$v['user_account'].',订单:'.$v['pay_order_number'].',操作:补单失败'; - $data[$k]['type'] = $type; - $data[$k]['url'] = U('Spend/lists',array('pay_order_number'=>$v['pay_order_number'])); - $data[$k]['create_time'] = time(); - $data[$k]['status']=0; - $data[$k]['position'] = $v['id']; - } - return $data; - }else { - D('check')->dealWithCheckListOnNull($type); - return ''; - } - - } + /** + * 累计流水 + * @param $map + * @return mixed + * author: xmy 280564871@qq.com + */ + public function getTotalSpend($map) + { + $map['pay_status'] = 1; + $data = $this->field("IFNULL(sum(pay_amount),0) as num")->where($map)->find(); + return $data; + } + /* + * 游戏充值未到账列表 + * @return array 结果集 + * @author 鹿文学 + */ + public function checkSpend() + { - /** - * 统计总流水 - * @param array $where 条件数组 - * @return integer 数量 - * @author 鹿文学 - */ - public function totalAmount($map=array()) { + $list = $this->field('id,user_id,user_account,game_id,game_name,pay_amount,pay_order_number')->where(array('pay_status' => 0))->select(); + $type = 101; + if ($list[0]) { - $map['pay_status'] = 1; + $list = D('check')->dealWithCheckList($type, $list); - $sum = $this->where($map)->sum('pay_amount'); - - return $sum?$sum:0; + if (empty($list[0])) { + return ''; + } - } + foreach ($list as $k => $v) { + $data[$k]['info'] = '玩家:' . $v['user_account'] . ',游戏[' . $v['game_name'] . ']充值金额:' . $v['pay_amount'] . ',订单状态:下单未支付'; + $data[$k]['type'] = $type; + $data[$k]['url'] = U('Spend/lists', array('pay_order_number' => $v['pay_order_number'])); + $data[$k]['create_time'] = time(); + $data[$k]['status'] = 0; + $data[$k]['position'] = $v['id']; + } + return $data; + } else { + D('check')->dealWithCheckListOnNull($type); + return ''; + } + } - /** - * 分组统计流水 - * @param array $map 条件数组 - * @param string $fieldname 字段别名 - * @param string $group 分组字段名 - * @param integer $flag 时间类别(1:天,2:月,3:周) - * @return array 详细数据 - * @author 鹿文学 - */ - public function totalAmountByGroup($map=array(),$fieldname='amount',$group='time',$flag=1,$order='time') { + /* + * 游戏补单列表 + * @return array 结果集 + * @author 鹿文学 + */ + public function checkSupplement() + { - switch($flag) { - case 2:{$dateform = '%Y-%m';};break; - case 3:{$dateform = '%Y-%u';};break; - case 4:{$dateform = '%Y';};break; - case 5:{$dateform = '%Y-%m-%d %H';};break; - default:$dateform = '%Y-%m-%d'; - } + $list = $this->field('id,user_id,user_account,pay_order_number')->where(array('pay_status' => 1, 'pay_game_status' => 0))->select(); + $type = 102; + if ($list[0]) { - $map['pay_status']=1; + $list = D('check')->dealWithCheckList($type, $list); + if (empty($list[0])) { + return ''; + } - $data = $this->field('FROM_UNIXTIME(pay_time,"'.$dateform.'") as '.$group.',sum(pay_amount) as '.$fieldname) + foreach ($list as $k => $v) { + $data[$k]['info'] = '玩家:' . $v['user_account'] . ',订单:' . $v['pay_order_number'] . ',操作:补单失败'; + $data[$k]['type'] = $type; + $data[$k]['url'] = U('Spend/lists', array('pay_order_number' => $v['pay_order_number'])); + $data[$k]['create_time'] = time(); + $data[$k]['status'] = 0; + $data[$k]['position'] = $v['id']; + } + return $data; + } else { + D('check')->dealWithCheckListOnNull($type); + return ''; + } - ->where($map)->group($group)->order($order)->select(); + } - return $data; - } - /** - * 分组统计所有流水 - * @param array $map 条件数组 - * @param string $fieldname 字段别名 - * @param string $group 分组字段名 - * @param integer $flag 时间类别(1:天,2:月,3:周) - * @return array 详细数据 - * @author 鹿文学 - */ - public function allAmountByGroup($map=array(),$fieldname='amount',$group='time',$flag=1,$order='time') { + /** + * 统计总流水 + * @param array $where 条件数组 + * @return integer 数量 + * @author 鹿文学 + */ + public function totalAmount($map = array()) + { - switch($flag) { - case 2:{$dateform = '%Y-%m';};break; - case 3:{$dateform = '%Y-%u';};break; - case 4:{$dateform = '%Y';};break; - case 5:{$dateform = '%Y-%m-%d %H';};break; - default:$dateform = '%Y-%m-%d'; - } + $map['pay_status'] = 1; - $map['pay_status']=1; + $sum = $this->where($map)->sum('pay_amount'); - $union = D('deposit')->field('pay_order_number,FROM_UNIXTIME(create_time,"'.$dateform.'") as '.$group.',sum(pay_amount) as '.$fieldname) + return $sum ? $sum : 0; - ->where(['create_time'=>$map['pay_time'],'pay_status'=>1]) + } - ->group($group)->select(false); + /** + * 分组统计流水 + * @param array $map 条件数组 + * @param string $fieldname 字段别名 + * @param string $group 分组字段名 + * @param integer $flag 时间类别(1:天,2:月,3:周) + * @return array 详细数据 + * @author 鹿文学 + */ + public function totalAmountByGroup($map = array(), $fieldname = 'amount', $group = 'time', $flag = 1, $order = 'time') + { - $bind = M('Bind_recharge','tab_')->field('pay_order_number,FROM_UNIXTIME(create_time,"'.$dateform.'") as '.$group.',sum(real_amount) as '.$fieldname) + switch ($flag) { + case 2: + { + $dateform = '%Y-%m'; + }; + break; + case 3: + { + $dateform = '%Y-%u'; + }; + break; + case 4: + { + $dateform = '%Y'; + }; + break; + case 5: + { + $dateform = '%Y-%m-%d %H'; + }; + break; + default: + $dateform = '%Y-%m-%d'; + } - ->where(['create_time'=>$map['pay_time'],'pay_status'=>1]) + $map['pay_status'] = 1; - ->group($group)->select(false); + $data = $this->field('FROM_UNIXTIME(pay_time,"' . $dateform . '") as ' . $group . ',sum(pay_amount) as ' . $fieldname) + ->where($map)->group($group)->order($order)->select(); - $sql = $this->field('pay_order_number,FROM_UNIXTIME(pay_time,"'.$dateform.'") as '.$group.',sum(pay_amount) as '.$fieldname) + return $data; + } - ->union('('.$union.')') + /** + * 分组统计所有流水 + * @param array $map 条件数组 + * @param string $fieldname 字段别名 + * @param string $group 分组字段名 + * @param integer $flag 时间类别(1:天,2:月,3:周) + * @return array 详细数据 + * @author 鹿文学 + */ + public function allAmountByGroup($map = array(), $fieldname = 'amount', $group = 'time', $flag = 1, $order = 'time') + { - ->union('('.$bind.')') + switch ($flag) { + case 2: + { + $dateform = '%Y-%m'; + }; + break; + case 3: + { + $dateform = '%Y-%u'; + }; + break; + case 4: + { + $dateform = '%Y'; + }; + break; + case 5: + { + $dateform = '%Y-%m-%d %H'; + }; + break; + default: + $dateform = '%Y-%m-%d'; + } - ->where($map)->group($group)->select(false); + $map['pay_status'] = 1; - $data = $this->table('('.$sql.') as a')->field('a.'.$group.',sum(a.'.$fieldname.') as '.$fieldname)->group('a.'.$group)->order($order)->select(); + $union = D('deposit')->field('pay_order_number,FROM_UNIXTIME(create_time,"' . $dateform . '") as ' . $group . ',sum(pay_amount) as ' . $fieldname) + ->where(['create_time' => $map['pay_time'], 'pay_status' => 1]) + ->group($group)->select(false); - return $data; - } - /* - * 付费用户 - * @param array $map 条件数组 - * @param string $fieldname 字段别名 - * @param string $group 分组字段名 - * @param integer $flag 时间类别(1:天,2:月,3:周) - * @return array 详细数据 - * @author 鹿文学 - */ - public function totalPlayerByGroup($map=array(),$fieldname='count',$group='time',$flag=1,$order='time') { + $bind = M('Bind_recharge', 'tab_')->field('pay_order_number,FROM_UNIXTIME(create_time,"' . $dateform . '") as ' . $group . ',sum(real_amount) as ' . $fieldname) + ->where(['create_time' => $map['pay_time'], 'pay_status' => 1]) + ->group($group)->select(false); - switch($flag) { - case 2:{$dateform = '%Y-%m';};break; - case 3:{$dateform = '%Y-%u';};break; - case 4:{$dateform = '%Y';};break; - case 5:{$dateform = '%Y-%m-%d %H';};break; - default:$dateform = '%Y-%m-%d'; - } - $map['pay_status']=1; + $sql = $this->field('pay_order_number,FROM_UNIXTIME(pay_time,"' . $dateform . '") as ' . $group . ',sum(pay_amount) as ' . $fieldname) + ->union('(' . $union . ')') + ->union('(' . $bind . ')') + ->where($map)->group($group)->select(false); + $data = $this->table('(' . $sql . ') as a')->field('a.' . $group . ',sum(a.' . $fieldname . ') as ' . $fieldname)->group('a.' . $group)->order($order)->select(); - $data = $this->field('FROM_UNIXTIME(pay_time,"'.$dateform.'") as '.$group.',count( DISTINCT user_id) as '.$fieldname) + return $data; + } - ->where($map)->group($group)->order($order)->select(); + /* + * 付费用户 + * @param array $map 条件数组 + * @param string $fieldname 字段别名 + * @param string $group 分组字段名 + * @param integer $flag 时间类别(1:天,2:月,3:周) + * @return array 详细数据 + * @author 鹿文学 + */ + public function totalPlayerByGroup($map = array(), $fieldname = 'count', $group = 'time', $flag = 1, $order = 'time') + { - return $data; + switch ($flag) { + case 2: + { + $dateform = '%Y-%m'; + }; + break; + case 3: + { + $dateform = '%Y-%u'; + }; + break; + case 4: + { + $dateform = '%Y'; + }; + break; + case 5: + { + $dateform = '%Y-%m-%d %H'; + }; + break; + default: + $dateform = '%Y-%m-%d'; + } - } + $map['pay_status'] = 1; - /* - * 付费用户 - * @param integer $start 开始时间戳 - * @param integer $end 结束时间戳 - * @param string $fieldname 字段别名 - * @param string $group 分组字段名 - * @param integer $flag 时间类别(1:天,2:月,3:周) - * @return array 详细数据 - * @author 鹿文学 - */ - public function totalPlayerByTime($start,$end,$fieldname='count',$group='time',$flag=1,$order='time') { - switch($flag) { - case 2:{$dateform = '%Y-%m';};break; - case 3:{$dateform = '%Y-%u';};break; - case 4:{$dateform = '%Y';};break; - case 5:{$dateform = '%Y-%m-%d %H';};break; - default:$dateform = '%Y-%m-%d'; - } + $data = $this->field('FROM_UNIXTIME(pay_time,"' . $dateform . '") as ' . $group . ',count( DISTINCT user_id) as ' . $fieldname) + ->where($map)->group($group)->order($order)->select(); - $map['pay_status']=1; + return $data; - $map['create_time'] = ['between',[$start,$end]]; + } - $bindrecharge_data = M('bind_recharge','tab_')->field('FROM_UNIXTIME(create_time,"'.$dateform.'") as '.$group.',GROUP_CONCAT( DISTINCT user_id) as user_id') - ->where($map)->group($group)->select(false); + /* + * 付费用户 + * @param integer $start 开始时间戳 + * @param integer $end 结束时间戳 + * @param string $fieldname 字段别名 + * @param string $group 分组字段名 + * @param integer $flag 时间类别(1:天,2:月,3:周) + * @return array 详细数据 + * @author 鹿文学 + */ + public function totalPlayerByTime($start, $end, $fieldname = 'count', $group = 'time', $flag = 1, $order = 'time') + { - $deposit_data = M('deposit','tab_')->field('FROM_UNIXTIME(create_time,"'.$dateform.'") as '.$group.',GROUP_CONCAT( DISTINCT user_id) as user_id') - ->where($map)->group($group)->select(false); + switch ($flag) { + case 2: + { + $dateform = '%Y-%m'; + }; + break; + case 3: + { + $dateform = '%Y-%u'; + }; + break; + case 4: + { + $dateform = '%Y'; + }; + break; + case 5: + { + $dateform = '%Y-%m-%d %H'; + }; + break; + default: + $dateform = '%Y-%m-%d'; + } - $map['pay_way'] = array('gt',0); - unset($map['create_time']); - $map['pay_time'] = ['between',[$start,$end]]; + $map['pay_status'] = 1; - $lists = $this->field('FROM_UNIXTIME(pay_time,"'.$dateform.'") as '.$group.',GROUP_CONCAT( DISTINCT user_id) as user_id') + $map['create_time'] = ['between', [$start, $end]]; - ->union(' ('.$bindrecharge_data.') ')->union(' ('.$deposit_data.') ') + $bindrecharge_data = M('bind_recharge', 'tab_')->field('FROM_UNIXTIME(create_time,"' . $dateform . '") as ' . $group . ',GROUP_CONCAT( DISTINCT user_id) as user_id') + ->where($map)->group($group)->select(false); - ->where($map)->group($group)->select(false); + $deposit_data = M('deposit', 'tab_')->field('FROM_UNIXTIME(create_time,"' . $dateform . '") as ' . $group . ',GROUP_CONCAT( DISTINCT user_id) as user_id') + ->where($map)->group($group)->select(false); - $lists = $this->field('a.'.$group.',GROUP_CONCAT(a.user_id) as user_id')->table(' ('.$lists.') as a')->group('a.'.$group)->order('a.'.$order)->select(); + $map['pay_way'] = array('gt', 0); + unset($map['create_time']); + $map['pay_time'] = ['between', [$start, $end]]; - $data = []; + $lists = $this->field('FROM_UNIXTIME(pay_time,"' . $dateform . '") as ' . $group . ',GROUP_CONCAT( DISTINCT user_id) as user_id') + ->union(' (' . $bindrecharge_data . ') ')->union(' (' . $deposit_data . ') ') + ->where($map)->group($group)->select(false); - foreach($lists as $k=>$v) { - $userid = array_unique(explode(',',$v['user_id'])); - $data[$k] = array( - $group => $v[$group], - $fieldname=>count($userid), - ); - } + $lists = $this->field('a.' . $group . ',GROUP_CONCAT(a.user_id) as user_id')->table(' (' . $lists . ') as a')->group('a.' . $group)->order('a.' . $order)->select(); - return $data; + $data = []; - } + foreach ($lists as $k => $v) { + $userid = array_unique(explode(',', $v['user_id'])); + $data[$k] = array( + $group => $v[$group], + $fieldname => count($userid), + ); + } - /* - * 付费用户总数 - * @param array $map 条件数组 - * @author 鹿文学 - */ - public function player($map=array()) { + return $data; - $map['pay_status']=1; + } - $data = $this->field('count( DISTINCT user_id) as count') + /* + * 付费用户总数 + * @param array $map 条件数组 + * @author 鹿文学 + */ + public function player($map = array()) + { - ->where($map)->select(); + $map['pay_status'] = 1; - return $data[0]?$data[0]['count']:0; + $data = $this->field('count( DISTINCT user_id) as count') + ->where($map)->select(); - } + return $data[0] ? $data[0]['count'] : 0; - /* - * 付费总数 - * @param array $map 条件数组 - * @author 鹿文学 - */ - public function amount($map=array()) { + } - $map['pay_status'] = 1; + /* + * 付费总数 + * @param array $map 条件数组 + * @author 鹿文学 + */ + public function amount($map = array()) + { - $data = $this + $map['pay_status'] = 1; - ->where($map)->sum('pay_amount'); + $data = $this + ->where($map)->sum('pay_amount'); - return $data?$data:0; - } + return $data ? $data : 0; + } /** * 列表 @@ -701,59 +776,53 @@ protected function _after_select(&$result,$options){ * * @return mixed * - * @author: 鹿文学[lwx] - * @since: 2019\4\11 0011 13:40 * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException + * @author: 鹿文学[lwx] + * @since: 2019\4\11 0011 13:40 */ - public function lists($p=1, $map=array(), $order, $field=true) + public function lists($p = 1, $map = array(), $order, $field = true) { - - $page = intval($p); - - $page = $page ? $page : 1; //默认显示第一页数据 - - if(isset($_REQUEST['row'])) { + $page = intval($p); + $page = $page ? $page : 1; //默认显示第一页数据 + if (isset($_REQUEST['row'])) { $row = $_REQUEST['row']; } else { $row = 10; } - $list = $this->field("tab_spend.*") - ->join("left join tab_promote as tp on tp.id = tab_spend.promote_id") - ->where($map) - ->page($page, $row) - ->order($order?$order:'tab_spend.pay_time desc') - ->select(); - - $count = $this->where($map)->join("left join tab_promote as tp on tp.id = tab_spend.promote_id")->count(); - + $list = $this + ->where($map) + ->page($page, $row) + ->order($order ? $order : 'pay_time desc') + ->select(); + $count = $this->where($map)->count(); $data['data'] = $list; - - $page = set_pagination($count,$row); - - if($page) { - $data['page']=$page; + $page = set_pagination($count, $row); + if ($page) { + $data['page'] = $page; } return $data; - } + } /** * 获取统计 $map,$page,$row */ - public function getSpendData($map=[],$field='',$group='',$order='',$page = 0,$row = 0) { + public function getSpendData($map = [], $field = '', $group = '', $order = '', $page = 0, $row = 0) + { if ($row == 0) { $data = $this->field($field)->where($map)->group($group)->order($order)->select(); } else { - $data = $this->field($field)->where($map)->page($page,$row)->group($group)->order($order)->select(); + $data = $this->field($field)->where($map)->page($page, $row)->group($group)->order($order)->select(); } return $data; } - public function sumSpend($map=[],$field='') { + public function sumSpend($map = [], $field = '') + { $sum = $this->where($map)->sum($field); return $sum; diff --git a/Application/Admin/View/Spend/lists.html b/Application/Admin/View/Spend/lists.html index 154a3b6ad..bbe37a995 100644 --- a/Application/Admin/View/Spend/lists.html +++ b/Application/Admin/View/Spend/lists.html @@ -48,11 +48,11 @@
- -
-
@@ -67,19 +67,11 @@
-