|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Admin\Controller;
|
|
|
|
use User\Api\UserApi as UserApi;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 后台首页控制器
|
|
|
|
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
|
|
|
|
*/
|
|
|
|
class RefundController extends ThinkController {
|
|
|
|
public function userCount(){
|
|
|
|
if(!array_key_exists("count_date",$_REQUEST) && !array_key_exists("user_account",$_REQUEST)){
|
|
|
|
$this->redirect(ACTION_NAME, array('count_date' => date('Y-m')));
|
|
|
|
}
|
|
|
|
$page = I('p', 1);
|
|
|
|
$row = I('row', 10);
|
|
|
|
|
|
|
|
if(isset($_REQUEST['user_account'])){
|
|
|
|
$map['user_account']=array('like','%'.trim($_REQUEST['user_account']).'%');
|
|
|
|
}
|
|
|
|
if(isset($_REQUEST['count_date'])){
|
|
|
|
$map['pay_time'] = ["BETWEEN",$this->getMonthTimeRange($_REQUEST['count_date'])];
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
$model = SM("spend_refund",'tab_');
|
|
|
|
$data = $model
|
|
|
|
->where($map)
|
|
|
|
->group("month,user_id")
|
|
|
|
->order("month desc,refund_amount desc");
|
|
|
|
if(isset($_REQUEST['export'])){
|
|
|
|
$data = $data->field("CONCAT(' ',FROM_UNIXTIME(`pay_time`,'%Y-%m')) as month,user_id,user_account,sum(refund_amount) refund_amount")->select();
|
|
|
|
data2csv($data,'退款统计',array(
|
|
|
|
"month"=>"月份",
|
|
|
|
"user_account"=>"玩家账号",
|
|
|
|
"refund_amount"=>"退款金额"
|
|
|
|
));
|
|
|
|
}
|
|
|
|
$data = $data->field("FROM_UNIXTIME(`pay_time`,'%Y-%m') as month,user_id,user_account,sum(refund_amount) refund_amount")->page($page, $row)->select();
|
|
|
|
foreach ($data as $k => &$v) {
|
|
|
|
$between = $this->getMonthTimeRange($v['month'],true);
|
|
|
|
$v['jump_url'] = U("Spend/lists",['timestart'=>$between[0],'timeend'=>$between[1],'user_account'=>$v['user_account'],'is_refund'=>1]);
|
|
|
|
}
|
|
|
|
$allcount = $model->where($map)->getField("sum(refund_amount) refund_amount");
|
|
|
|
|
|
|
|
$count_sql = $model->field("FROM_UNIXTIME(`pay_time`,'%Y-%m') as month,user_id")->group("month,user_id")->where($map)->select(false);
|
|
|
|
$count = SM()->table( '('.$count_sql.') a' )->count();
|
|
|
|
|
|
|
|
$page = set_pagination($count, $row);
|
|
|
|
if ($page) {
|
|
|
|
$this->assign('_page', $page);
|
|
|
|
}
|
|
|
|
$this->assign("allcount",$allcount);
|
|
|
|
$this->assign("data",$data);
|
|
|
|
$this->assign("date_count",showMonthRange('2019-09-01',date('Y-m-d',time())));
|
|
|
|
$this->display();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getMonthTimeRange($date,$isdate = false)
|
|
|
|
{
|
|
|
|
$start = strtotime( $date . "-1 00:00:00" );
|
|
|
|
$mdays = date('t', $start);
|
|
|
|
if($isdate){
|
|
|
|
return [$date."-1",$date.'-'.$mdays];
|
|
|
|
}
|
|
|
|
$end = strtotime( $date.'-'.$mdays.' 23:59:59');
|
|
|
|
return [$start,$end];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// public function lists(){
|
|
|
|
// if(isset($_REQUEST['user_account'])){
|
|
|
|
// $map['user_account']=array('like','%'.trim($_REQUEST['user_account']).'%');
|
|
|
|
// unset($_REQUEST['user_account']);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if(isset($_REQUEST['time-start'])&&isset($_REQUEST['time-end'])){
|
|
|
|
// $map['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']);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if(isset($_REQUEST['game_name'])){
|
|
|
|
// if($_REQUEST['game_name']=='全部'){
|
|
|
|
// unset($_REQUEST['game_name']);
|
|
|
|
// }else{
|
|
|
|
// $map['game_name']=$_REQUEST['game_name'];
|
|
|
|
// unset($_REQUEST['game_name']);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// 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['tui_status']=$_REQUEST['pay_status'];
|
|
|
|
// unset($_REQUEST['pay_status']);
|
|
|
|
// }
|
|
|
|
// if(isset($_REQUEST['pay_way'])){
|
|
|
|
// $map['pay_way']=$_REQUEST['pay_way'];
|
|
|
|
// unset($_REQUEST['pay_way']);
|
|
|
|
// }
|
|
|
|
// $model = array(
|
|
|
|
// 'm_name' => 'RefundRecord',
|
|
|
|
// 'map' => $map,
|
|
|
|
// 'order' =>'id desc',
|
|
|
|
// 'title' => '退款记录',
|
|
|
|
// 'template_list' =>'lists',
|
|
|
|
// );
|
|
|
|
// $total=null_to_0(M('RefundRecord','tab_')->where(['tui_status'=>1])->sum('tui_amount'));
|
|
|
|
// $ttotal=null_to_0(M('RefundRecord','tab_')->where('pay_time'.total(1))->where(array('tui_status'=>1))->sum('tui_amount'));
|
|
|
|
// $ytotal=null_to_0(M('RefundRecord','tab_')->where('pay_time'.total(5))->where(array('tui_status'=>1))->sum('tui_amount'));
|
|
|
|
// $this->assign('total',$total);
|
|
|
|
// $this->assign('ttotal',$ttotal);
|
|
|
|
// $this->assign('ytotal',$ytotal);
|
|
|
|
// $user = A('User','Event');
|
|
|
|
// $user->user_join_($model,$_GET['p']);
|
|
|
|
// }
|
|
|
|
|
|
|
|
}
|