@ -49,17 +49,29 @@ class PayChannelIntentionController extends AdminController
}
if ($_REQUEST['pay_type']) {
$map['pay_ways'] = ['like',"%, {$_REQUEST['pay_type']}"];
$map['pay_ways'] = ['like',"%{$_REQUEST['pay_type']}"];
}
$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,create_time')
->field('id, 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,max( create_time) m _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 DESC')
->select(false);
$show_data = M('pay_channel_intention','tab_')
->field("a.pay_amount,pay_ways,a.user_account,a.pay_order_number,tab_pay_channel_intention.create_time,CASE WHEN is_submit = 1 THEN tab_pay_channel_intention.pay_status ELSE 2 END as pay_status")
->join("left join ({$show_data}) as a on tab_pay_channel_intention.pay_order_number=a.pay_order_number and tab_pay_channel_intention.create_time=m_time")
->where('pay_ways is not null')
// ->group('tab_pay_channel_intention.pay_order_number')
->order('tab_pay_channel_intention.id DESC')
->select(false);
$show_data = M()->table('('.$show_data.') as a')
->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,
@ -72,6 +84,14 @@ class PayChannelIntentionController extends AdminController
->group('a.pay_ways,a.user_account,a.pay_status')
->select(false);
// dump($data);die();
$count = M()->table('('.$data.') as a')
->field('pay_ways,sum(fail_invest_amount) fail_invest_amount')
->where($map)
->group('a.pay_ways')
->select(false);
// dump($count);die();
$data = M()->table('('.$data.') as a')
->field('pay_ways,sum(fail_invest_amount) fail_invest_amount,create_time,
sum(success_invest_amount) success_invest_amount,
@ -93,9 +113,23 @@ class PayChannelIntentionController extends AdminController
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);
$sum = M()->table('('.$sum.') as a')
->field('pay_ways,user_account,pay_status,create_time,
SUM(if(pay_status=0,fail_invest_amount,0)) fail_invest_amount,
SUM(if(pay_status=1,success_invest_amount,0)) success_invest_amount,
SUM(if(pay_status=2,nothing_invest_amount,0)) nothing_invest_amount,
count(if(pay_status=0,fail_invest_count,null)) fail_invest_count,
count(if(pay_status=1,success_invest_count,null)) success_invest_count,
count(if(pay_status=2,nothing_invest_count,null)) nothing_invest_count')
->group('a.user_account,a.pay_status')
->select(false);
// dump($sum);die();
$sum = M()->table('('.$sum.') as a')
->field('pay_ways,sum(fail_invest_amount) fail_invest_amount,
sum(success_invest_amount) success_invest_amount,
@ -103,16 +137,13 @@ class PayChannelIntentionController extends AdminController
count(if(pay_status=0,fail_invest_count,NULL)) fail_invest_count,
count(if(pay_status=1,success_invest_count,NULL)) success_invest_count,
count(if(pay_status=2,nothing_invest_count,NULL)) nothing_invest_count')
->where($map)
->find();
// dump($sum);die();
$this->assign('sum',$sum);
$count = M()->table('('.$show_data.') as a')
->field('count(pay_amount) count')
->group('a.pay_ways')
->select(false);
$count = M()->table('('.$count.') as a')->count();
@ -165,17 +196,29 @@ class PayChannelIntentionController extends AdminController
}
if ($_REQUEST['pay_type']) {
$map['pay_ways'] = ['like',"%, {$_REQUEST['pay_type']}"];
$map['pay_ways'] = ['like',"%{$_REQUEST['pay_type']}"];
}
$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')
->field('id, 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,max(create_time) m_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 DESC')
->select(false);
$show_data = M('pay_channel_intention','tab_')
->field("a.pay_amount,pay_ways,a.user_account,a.pay_order_number,tab_pay_channel_intention.create_time,CASE WHEN is_submit = 1 THEN tab_pay_channel_intention.pay_status ELSE 2 END as pay_status")
->join("left join ({$show_data}) as a on tab_pay_channel_intention.pay_order_number=a.pay_order_number and tab_pay_channel_intention.create_time=m_time")
->where('pay_ways is not null')
// ->group('tab_pay_channel_intention.pay_order_number')
->order('tab_pay_channel_intention.id DESC')
->select(false);
$show_data = M()->table('('.$show_data.') as a')
->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,
@ -183,8 +226,8 @@ 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);
@ -218,10 +261,10 @@ class PayChannelIntentionController extends AdminController
->field('"" as pay_ways_ch,"" as pay_way,pay_ways,user_account,
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')
sum(fail_invest_amount) fail_invest_amount,
count(if(pay_status=2,nothing_invest_count,NULL)) nothing_invest_count,
sum(nothing_invest_amount) nothing_invest_amount')
->limit(($i-1)*$perSize ,$perSize)
->where($map)
->group('a.pay_ways')
@ -265,13 +308,24 @@ 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,
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);
$sum = M()->table('('.$sum.') as a')
->field('pay_ways,user_account,pay_status,create_time,
SUM(if(pay_status=0,fail_invest_amount,0)) fail_invest_amount,
SUM(if(pay_status=1,success_invest_amount,0)) success_invest_amount,
SUM(if(pay_status=2,nothing_invest_amount,0)) nothing_invest_amount,
count(if(pay_status=0,fail_invest_count,null)) fail_invest_count,
count(if(pay_status=1,success_invest_count,null)) success_invest_count,
count(if(pay_status=2,nothing_invest_count,null)) nothing_invest_count')
->group('a.user_account,a.pay_status')
->select(false);
@ -279,34 +333,14 @@ class PayChannelIntentionController extends AdminController
->field('"汇总(检索时间内所有数据的统计)" pay_ways,"" other,
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
sum(fail_invest_amount) fail_invest_amount,
count(if(pay_status=2,nothing_invest_count,NULL)) nothing_invest_count,
sum(nothing_invest_amount) nothing_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);
//刷新输出缓冲到浏览器
@ -334,9 +368,14 @@ class PayChannelIntentionController extends AdminController
$map = [];
if ($_REQUEST['pay_way']) {
$map['pay_ways'] = $_REQUEST['pay_way'];
}
if ($_REQUEST['pay_ways']) {
$map['pay_ways'] = $_REQUEST['pay_ways'];
$map['pay_ways'] = ['like',"%{ $_REQUEST['pay_ways']}" ];
}
// var_dump($map);die();
if ($_REQUEST['user_account']) {
$map['user_account'] = $_REQUEST['user_account'];
@ -369,25 +408,35 @@ class PayChannelIntentionController extends AdminController
// $map['create_time'] = ['elt',strtotime($_REQUEST['time_end'])];
}
// var_dump($map);die();
$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,
->field('id, 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="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,
CASE WHEN is_submit = 0 THEN 2 ELSE pay_game_status END as pay_game_status,
tab_pay_channel_intention.pay_order_number,tab_pay_channel_intention.create_time')
tab_pay_channel_intention.pay_order_number,tab_pay_channel_intention.create_time,max(create_time) m_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 DESC')
->order('tab_pay_channel_intention.id DESC')
->select(false);
$data = M('pay_channel_intention','tab_')
->field('a.*,
CASE WHEN is_submit = 0 THEN 2 ELSE pay_status END as pay_status,
CASE WHEN is_submit = 0 THEN 2 ELSE pay_game_status END as pay_game_status')
->join("left join ({$data}) as a on tab_pay_channel_intention.pay_order_number=a.pay_order_number and tab_pay_channel_intention.create_time=m_time")
->where('pay_ways is not null')
->select(false);
// var_dump($data);die();
// dump($data);die();
$count = M()->table('('.$data.') as a')
->field('id')
->where($map)
->count();
@ -410,14 +459,20 @@ class PayChannelIntentionController extends AdminController
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,
CASE WHEN is_submit = 0 THEN 2 ELSE pay_game_status END as pay_game_status,
tab_pay_channel_intention.pay_order_number,tab_pay_channel_intention.create_time')
tab_pay_channel_intention.pay_order_number,tab_pay_channel_intention.create_time,max(create_time) m_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')
->select(false);
$sum = M('pay_channel_intention','tab_')
->field('a.*,
CASE WHEN is_submit = 0 THEN 2 ELSE pay_status END as pay_status,
CASE WHEN is_submit = 0 THEN 2 ELSE pay_game_status END as pay_game_status')
->join("left join ({$sum}) as a on tab_pay_channel_intention.pay_order_number=a.pay_order_number and tab_pay_channel_intention.create_time=m_time")
->where('pay_ways is not null')
->select(false);
$sum = M()->table('('.$sum.') as a')
->field("sum(pay_amount) pay_amount,sum(alipay) alipay,sum(wxpay) wxpay,sum(sqshorcut) sqshorcut,sum(shorcut) shorcut")
->where($map)
@ -477,19 +532,26 @@ class PayChannelIntentionController extends AdminController
}
$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,
->field('id, 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="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,
CASE WHEN is_submit = 0 THEN 2 ELSE pay_game_status END as pay_game_status,
tab_pay_channel_intention.pay_order_number,tab_pay_channel_intention.create_time')
tab_pay_channel_intention.pay_order_number,tab_pay_channel_intention.create_time,max(create_time) m_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 DESC')
->order('tab_pay_channel_intention.id DESC')
->select(false);
$data = M('pay_channel_intention','tab_')
->field('a.*,
CASE WHEN is_submit = 0 THEN 2 ELSE pay_status END as pay_status,
CASE WHEN is_submit = 0 THEN 2 ELSE pay_game_status END as pay_game_status')
->join("left join ({$data}) as a on tab_pay_channel_intention.pay_order_number=a.pay_order_number and tab_pay_channel_intention.create_time=m_time")
->where('pay_ways is not null')
->select(false);
$csvFileName = $xlsName.'.csv';
@ -559,14 +621,20 @@ class PayChannelIntentionController extends AdminController
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,
CASE WHEN is_submit = 0 THEN 2 ELSE pay_game_status END as pay_game_status,
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')
tab_pay_channel_intention.pay_order_number,tab_pay_channel_intention.create_time,max(create_time) m_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')
->select(false);
$sum = M('pay_channel_intention','tab_')
->field('a.*,
CASE WHEN is_submit = 0 THEN 2 ELSE pay_status END as pay_status,
CASE WHEN is_submit = 0 THEN 2 ELSE pay_game_status END as pay_game_status')
->join("left join ({$sum}) as a on tab_pay_channel_intention.pay_order_number=a.pay_order_number and tab_pay_channel_intention.create_time=m_time")
->where('pay_ways is not null')
->select(false);
$sum = M()->table('('.$sum.') as a')
->field("'汇总(检索时间内所有数据的统计)' as user_account,sum(pay_amount) pay_amount,sum(alipay) alipay,sum(wxpay) wxpay,sum(sqshorcut) sqshorcut,sum(shorcut) shorcut")
->where($map)