From f40bd576981bf425a51429d9628b97addf284267 Mon Sep 17 00:00:00 2001 From: zhengyongxing Date: Tue, 24 Mar 2020 18:34:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E4=BB=98=E6=B8=A0=E9=81=93=E6=84=8F?= =?UTF-8?q?=E6=84=BF=E7=BB=9F=E8=AE=A1bug=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PayChannelIntentionController.class.php | 148 +++++++++++++----- .../View/PayChannelIntention/detail.html | 20 ++- Data/update.sql | 9 +- 3 files changed, 140 insertions(+), 37 deletions(-) diff --git a/Application/Admin/Controller/PayChannelIntentionController.class.php b/Application/Admin/Controller/PayChannelIntentionController.class.php index d89f5ef4f..bcb7bd741 100644 --- a/Application/Admin/Controller/PayChannelIntentionController.class.php +++ b/Application/Admin/Controller/PayChannelIntentionController.class.php @@ -54,7 +54,7 @@ class PayChannelIntentionController extends AdminController $show_data = M('pay_channel_intention','tab_') ->field('group_concat(tab_pay_channel_intention.`pay_way` ORDER BY tab_pay_channel_intention.create_time ASC) as pay_ways,tab_pay_channel_intention.user_account, - tab_pay_channel_intention.pay_amount,CASE WHEN is_submit = 0 THEN 2 ELSE pay_status END as pay_status,tab_pay_channel_intention.pay_order_number') + tab_pay_channel_intention.pay_amount,CASE WHEN is_submit = 0 THEN 2 ELSE pay_status END as pay_status,tab_pay_channel_intention.pay_order_number,create_time') // ->join('left join tab_spend on tab_pay_channel_intention.pay_order_number=tab_spend.pay_order_number') ->group('tab_pay_channel_intention.pay_order_number') ->order('tab_pay_channel_intention.create_time ASC') @@ -67,13 +67,13 @@ class PayChannelIntentionController extends AdminController SUM(if(pay_status=2,pay_amount,0)) nothing_invest_amount, count(if(pay_status=0,pay_amount,null)) fail_invest_count, count(if(pay_status=1,pay_amount,null)) success_invest_count, - count(if(pay_status=2,pay_amount,null)) nothing_invest_count') - ->where($map) + count(if(pay_status=2,pay_amount,null)) nothing_invest_count,create_time') +// ->where($map) ->group('a.pay_ways,a.user_account,a.pay_status') ->select(false); $data = M()->table('('.$data.') as a') - ->field('pay_ways,sum(fail_invest_amount) fail_invest_amount, + ->field('pay_ways,sum(fail_invest_amount) fail_invest_amount,create_time, sum(success_invest_amount) success_invest_amount, sum(nothing_invest_amount) nothing_invest_amount, count(if(pay_status=0,fail_invest_count,NULL)) fail_invest_count, @@ -86,7 +86,7 @@ class PayChannelIntentionController extends AdminController $sum = M()->table('('.$show_data.') as a') - ->field('pay_ways,user_account,pay_status, + ->field('pay_ways,user_account,pay_status,create_time, SUM(if(pay_status=0,pay_amount,0)) fail_invest_amount, SUM(if(pay_status=1,pay_amount,0)) success_invest_amount, SUM(if(pay_status=2,pay_amount,0)) nothing_invest_amount, @@ -170,12 +170,24 @@ class PayChannelIntentionController extends AdminController $show_data = M('pay_channel_intention','tab_') ->field('group_concat(tab_pay_channel_intention.`pay_way` ORDER BY tab_pay_channel_intention.create_time ASC) as pay_ways,tab_pay_channel_intention.user_account, - tab_pay_channel_intention.pay_amount,CASE WHEN pay_status is null THEN 2 ELSE pay_status END as pay_status,tab_pay_channel_intention.pay_order_number') - ->join('left join tab_spend on tab_pay_channel_intention.pay_order_number=tab_spend.pay_order_number') + tab_pay_channel_intention.pay_amount,CASE WHEN is_submit = 0 THEN 2 ELSE pay_status END as pay_status,tab_pay_channel_intention.pay_order_number') +// ->join('left join tab_spend on tab_pay_channel_intention.pay_order_number=tab_spend.pay_order_number') ->group('tab_pay_channel_intention.pay_order_number') ->order('tab_pay_channel_intention.create_time ASC') ->select(false); + $data = M()->table('('.$show_data.') as a') + ->field('pay_ways,user_account,pay_status, + SUM(if(pay_status=0,pay_amount,0)) fail_invest_amount, + SUM(if(pay_status=1,pay_amount,0)) success_invest_amount, + SUM(if(pay_status=2,pay_amount,0)) nothing_invest_amount, + count(if(pay_status=0,pay_amount,null)) fail_invest_count, + count(if(pay_status=1,pay_amount,null)) success_invest_count, + count(if(pay_status=2,pay_amount,null)) nothing_invest_count') + ->where($map) + ->group('a.pay_ways,a.user_account,a.pay_status') + ->select(false); + $csvFileName = $xlsName.'.csv'; //设置好告诉浏览器要下载excel文件的headers header('Content-Description: File Transfer'); @@ -202,27 +214,38 @@ class PayChannelIntentionController extends AdminController for($i = 1; $i <= $pages; $i++) { - $xlsData = M()->table('('.$show_data.') as a') + $xlsData = M()->table('('.$data.') as a') ->field('"" as pay_ways_ch,"" as pay_way,pay_ways,user_account, - count(if(pay_status=1,pay_amount,null)) success_invest_count, - SUM(if(pay_status=1,pay_amount,0)) success_invest_amount, - count(if(pay_status=2,pay_amount,null)) nothing_invest_count, - SUM(if(pay_status=2,pay_amount,0)) nothing_invest_amount, - count(if(pay_status=0,pay_amount,null)) fail_invest_count, - SUM(if(pay_status=0,pay_amount,0)) fail_invest_amount') + count(if(pay_status=1,success_invest_count,NULL)) success_invest_count, + sum(success_invest_amount) success_invest_amount, + count(if(pay_status=2,nothing_invest_count,NULL)) nothing_invest_count, + sum(nothing_invest_amount) nothing_invest_amount, + count(if(pay_status=0,fail_invest_count,NULL)) fail_invest_count, + sum(fail_invest_amount) fail_invest_amount') ->limit(($i-1)*$perSize ,$perSize) ->where($map) - ->group('a.pay_ways,a.user_account,a.pay_status') + ->group('a.pay_ways') ->select(); +// $xlsData = M()->table('('.$show_data.') as a') +// ->field('"" as pay_ways_ch,"" as pay_way,pay_ways,user_account, +// count(if(pay_status=1,pay_amount,null)) success_invest_count, +// SUM(if(pay_status=1,pay_amount,0)) success_invest_amount, +// count(if(pay_status=2,pay_amount,null)) nothing_invest_count, +// SUM(if(pay_status=2,pay_amount,0)) nothing_invest_amount, +// count(if(pay_status=0,pay_amount,null)) fail_invest_count, +// SUM(if(pay_status=0,pay_amount,0)) fail_invest_amount') +// ->limit(($i-1)*$perSize ,$perSize) +// ->where($map) +// ->group('a.pay_ways,a.user_account,a.pay_status') +// ->select(); + foreach($xlsData as $key =>$value) { $arr = explode(',',$value['pay_ways']); $value['pay_way'] = self::$arr_pay_way[end($arr)]; - - $value['pay_ways_ch'] = ''; foreach ($arr as $k=>$v) { $value['pay_ways_ch'] = $value['pay_ways_ch'].($k+1).','.self::$arr_pay_way[$v]; @@ -242,25 +265,48 @@ class PayChannelIntentionController extends AdminController } $sum = M()->table('('.$show_data.') as a') - ->field('pay_ways,user_account, + ->field('pay_ways,user_account,pay_status, SUM(if(pay_status=0,pay_amount,0)) fail_invest_amount, SUM(if(pay_status=1,pay_amount,0)) success_invest_amount, SUM(if(pay_status=2,pay_amount,0)) nothing_invest_amount, count(if(pay_status=0,pay_amount,null)) fail_invest_count, count(if(pay_status=1,pay_amount,null)) success_invest_count, count(if(pay_status=2,pay_amount,null)) nothing_invest_count') - ->group('a.pay_ways') + ->group('a.user_account,a.pay_status') ->select(false); $sum = M()->table('('.$sum.') as a') - ->field('"" as pay_ways_ch,"" as pay_way, - sum(success_invest_count) success_invest_count, + ->field('"汇总(检索时间内所有数据的统计)" pay_ways,"" other, + count(if(pay_status=1,success_invest_count,NULL)) success_invest_count, sum(success_invest_amount) success_invest_amount, - sum(nothing_invest_count) nothing_invest_count, + count(if(pay_status=2,nothing_invest_count,NULL)) nothing_invest_count, sum(nothing_invest_amount) nothing_invest_amount, - sum(fail_invest_count) fail_invest_count, - sum(fail_invest_amount) fail_invest_amount') + count(if(pay_status=0,fail_invest_count,NULL)) fail_invest_count, + sum(fail_invest_amount) fail_invest_amount + ') + ->where($map) ->find(); + +// $sum = M()->table('('.$show_data.') as a') +// ->field('pay_ways,user_account, +// SUM(if(pay_status=0,pay_amount,0)) fail_invest_amount, +// SUM(if(pay_status=1,pay_amount,0)) success_invest_amount, +// SUM(if(pay_status=2,pay_amount,0)) nothing_invest_amount, +// count(if(pay_status=0,pay_amount,null)) fail_invest_count, +// count(if(pay_status=1,pay_amount,null)) success_invest_count, +// count(if(pay_status=2,pay_amount,null)) nothing_invest_count') +// ->group('a.pay_ways') +// ->select(false); +// +// $sum = M()->table('('.$sum.') as a') +// ->field('"" as pay_ways_ch,"" as pay_way, +// sum(success_invest_count) success_invest_count, +// sum(success_invest_amount) success_invest_amount, +// sum(nothing_invest_count) nothing_invest_count, +// sum(nothing_invest_amount) nothing_invest_amount, +// sum(fail_invest_count) fail_invest_count, +// sum(fail_invest_amount) fail_invest_amount') +// ->find(); mb_convert_variables('GBK', 'UTF-8', $sum); fputcsv($fp, $sum); //刷新输出缓冲到浏览器 @@ -298,18 +344,37 @@ class PayChannelIntentionController extends AdminController if ($_REQUEST['pay_status'] || $_REQUEST['pay_status'] == '0') { $map['pay_status'] = $_REQUEST['pay_status']; - if ($_REQUEST['pay_status'] == 3) { + + if ($_REQUEST['pay_status'] == 4) { $map['pay_status'] = 1; $map['pay_game_status'] = 1; } + + if ($_REQUEST['pay_status'] == 3) { + $map['pay_status'] = 1; + $map['pay_game_status'] = 0; + } + } + + if ($_REQUEST['timestart']&&!$_REQUEST['timeend']) { + $map['create_time'] = ['egt',strtotime($_REQUEST['timestart'])]; + } + + if (!$_REQUEST['timestart']&&$_REQUEST['timeend']) { + $map['create_time'] = ['elt',strtotime($_REQUEST['timeend'])+86399]; + } + + if ($_REQUEST['timestart']&&$_REQUEST['timeend']) { + $map['create_time'] = ['between',[strtotime($_REQUEST['timestart']),strtotime($_REQUEST['timeend'])+86399]]; +// $map['create_time'] = ['elt',strtotime($_REQUEST['time_end'])]; } $data = M('pay_channel_intention','tab_') ->field('group_concat(tab_pay_channel_intention.`pay_way` ORDER BY tab_pay_channel_intention.create_time ASC) as pay_ways, count(if(tab_pay_channel_intention.pay_way="alipay",tab_pay_channel_intention.pay_way,null)) alipay, count(if(tab_pay_channel_intention.pay_way="wxpay",tab_pay_channel_intention.pay_way,null)) wxpay, - count(if(tab_pay_channel_intention.pay_way="sqshorcut",tab_pay_channel_intention.pay_way,null)) sqshorcut, - count(if(tab_pay_channel_intention.pay_way="shorcut",tab_pay_channel_intention.pay_way,null)) shorcut, + count(if(tab_pay_channel_intention.pay_way="sqpay",tab_pay_channel_intention.pay_way,null)) sqshorcut, + count(if(tab_pay_channel_intention.pay_way="yeepay",tab_pay_channel_intention.pay_way,null)) shorcut, tab_pay_channel_intention.user_account, tab_pay_channel_intention.pay_amount, CASE WHEN is_submit = 0 THEN 2 ELSE pay_status END as pay_status, @@ -317,7 +382,7 @@ class PayChannelIntentionController extends AdminController tab_pay_channel_intention.pay_order_number,tab_pay_channel_intention.create_time') // ->join('left join tab_spend on tab_pay_channel_intention.pay_order_number=tab_spend.pay_order_number') ->group('tab_pay_channel_intention.pay_order_number') - ->order('tab_pay_channel_intention.create_time ASC') + ->order('tab_pay_channel_intention.create_time DESC') ->select(false); // var_dump($data);die(); @@ -341,8 +406,8 @@ class PayChannelIntentionController extends AdminController ->field('group_concat(tab_pay_channel_intention.`pay_way` ORDER BY tab_pay_channel_intention.create_time ASC) as pay_ways, count(if(tab_pay_channel_intention.pay_way="alipay",tab_pay_channel_intention.pay_way,null)) alipay, count(if(tab_pay_channel_intention.pay_way="wxpay",tab_pay_channel_intention.pay_way,null)) wxpay, - count(if(tab_pay_channel_intention.pay_way="sqshorcut",tab_pay_channel_intention.pay_way,null)) sqshorcut, - count(if(tab_pay_channel_intention.pay_way="shorcut",tab_pay_channel_intention.pay_way,null)) shorcut, + count(if(tab_pay_channel_intention.pay_way="sqpay",tab_pay_channel_intention.pay_way,null)) sqshorcut, + count(if(tab_pay_channel_intention.pay_way="yeepay",tab_pay_channel_intention.pay_way,null)) shorcut, tab_pay_channel_intention.user_account, tab_pay_channel_intention.pay_amount, CASE WHEN is_submit = 0 THEN 2 ELSE pay_status END as pay_status, @@ -398,12 +463,25 @@ class PayChannelIntentionController extends AdminController } } + if ($_REQUEST['timestart']&&!$_REQUEST['timeend']) { + $map['create_time'] = ['egt',strtotime($_REQUEST['timestart'])]; + } + + if (!$_REQUEST['timestart']&&$_REQUEST['timeend']) { + $map['create_time'] = ['elt',strtotime($_REQUEST['timeend'])+86399]; + } + + if ($_REQUEST['timestart']&&$_REQUEST['timeend']) { + $map['create_time'] = ['between',[strtotime($_REQUEST['timestart']),strtotime($_REQUEST['timeend'])+86399]]; +// $map['create_time'] = ['elt',strtotime($_REQUEST['time_end'])]; + } + $data = M('pay_channel_intention','tab_') ->field('group_concat(tab_pay_channel_intention.`pay_way` ORDER BY tab_pay_channel_intention.create_time ASC) as pay_ways, count(if(tab_pay_channel_intention.pay_way="alipay",tab_pay_channel_intention.pay_way,null)) alipay, count(if(tab_pay_channel_intention.pay_way="wxpay",tab_pay_channel_intention.pay_way,null)) wxpay, - count(if(tab_pay_channel_intention.pay_way="sqshorcut",tab_pay_channel_intention.pay_way,null)) sqshorcut, - count(if(tab_pay_channel_intention.pay_way="shorcut",tab_pay_channel_intention.pay_way,null)) shorcut, + count(if(tab_pay_channel_intention.pay_way="sqpay",tab_pay_channel_intention.pay_way,null)) sqshorcut, + count(if(tab_pay_channel_intention.pay_way="yeepay",tab_pay_channel_intention.pay_way,null)) shorcut, tab_pay_channel_intention.user_account, tab_pay_channel_intention.pay_amount, CASE WHEN is_submit = 0 THEN 2 ELSE pay_status END as pay_status, @@ -411,7 +489,7 @@ class PayChannelIntentionController extends AdminController tab_pay_channel_intention.pay_order_number,tab_pay_channel_intention.create_time') // ->join('left join tab_spend on tab_pay_channel_intention.pay_order_number=tab_spend.pay_order_number') ->group('tab_pay_channel_intention.pay_order_number') - ->order('tab_pay_channel_intention.create_time ASC') + ->order('tab_pay_channel_intention.create_time DESC') ->select(false); $csvFileName = $xlsName.'.csv'; @@ -477,8 +555,8 @@ class PayChannelIntentionController extends AdminController ->field('group_concat(tab_pay_channel_intention.`pay_way` ORDER BY tab_pay_channel_intention.create_time ASC) as pay_ways, count(if(tab_pay_channel_intention.pay_way="alipay",tab_pay_channel_intention.pay_way,null)) alipay, count(if(tab_pay_channel_intention.pay_way="wxpay",tab_pay_channel_intention.pay_way,null)) wxpay, - count(if(tab_pay_channel_intention.pay_way="sqshorcut",tab_pay_channel_intention.pay_way,null)) sqshorcut, - count(if(tab_pay_channel_intention.pay_way="shorcut",tab_pay_channel_intention.pay_way,null)) shorcut, + count(if(tab_pay_channel_intention.pay_way="sqpay",tab_pay_channel_intention.pay_way,null)) sqshorcut, + count(if(tab_pay_channel_intention.pay_way="yeepay",tab_pay_channel_intention.pay_way,null)) shorcut, tab_pay_channel_intention.user_account, tab_pay_channel_intention.pay_amount, CASE WHEN pay_status is null THEN 2 ELSE pay_status END as pay_status, diff --git a/Application/Admin/View/PayChannelIntention/detail.html b/Application/Admin/View/PayChannelIntention/detail.html index 8e5926099..147f5585f 100644 --- a/Application/Admin/View/PayChannelIntention/detail.html +++ b/Application/Admin/View/PayChannelIntention/detail.html @@ -229,7 +229,8 @@