From 5b74e6558536b049cc86026d8e4f31b9bbd75462 Mon Sep 17 00:00:00 2001 From: sunke <18850253506@163.com> Date: Tue, 17 Mar 2020 20:45:01 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/ExportController.class.php | 34 +++++++++++-------- .../Controller/FinanceController.class.php | 31 +++++++++++------ .../Admin/View/Finance/definiteDetaile.html | 7 ++-- .../Admin/View/Finance/valueDetail.html | 4 +-- 4 files changed, 47 insertions(+), 29 deletions(-) diff --git a/Application/Admin/Controller/ExportController.class.php b/Application/Admin/Controller/ExportController.class.php index f72412343..ae13496e3 100644 --- a/Application/Admin/Controller/ExportController.class.php +++ b/Application/Admin/Controller/ExportController.class.php @@ -2505,16 +2505,15 @@ class ExportController extends Controller $map2['create_time'] = $map['create_time']; $map2['pay_type'] = 2; - $deposit = M('value_detail_log', 'tab_')->where($map2)->sum('value'); - $deposit= empty($deposit) ? '0.00' : $deposit; - + $deposit1 = M('value_detail_log', 'tab_')->where($map2)->sum('value'); + $deposit1= empty($deposit1) ? '0.00' : $deposit1; $map3['create_time'] = $map['create_time']; $map3['pay_type'] = 3; $allpromoteCoin = M('value_detail_log', 'tab_')->where($map3)->sum('value'); $allpromoteCoin = empty($promoteCoin) ? '0.00' : $promoteCoin; $map4['create_time'] = $map['create_time']; - $banlace = M('value_detail_log', 'tab_')->field('user_id, after_value')->where($map4)->group('user_id')->select(); + $banlace = M('value_detail_log', 'tab_')->field('user_id, after_value')->where($map4)->order('create_time desc')->limit(1)->select(); $banlaceTotal = 0; foreach($banlace as $k222 => $vvv) { $banlaceTotal += $vvv['after_value']; @@ -2546,18 +2545,20 @@ class ExportController extends Controller ->select(); $allDatas = []; foreach($datas as $key => $data) { - $allDatas['user_id'] = $data['id']; $allDatas['user_account'] = $data['account']; - $spend = M('value_detail_log', 'tab_')->where(['user_id'=>$id, 'pay_type'=>1])->sum('value'); - $map5['user_id'] = $id; + $spend = M('value_detail_log', 'tab_')->where(['user_id'=>$data['id'], 'pay_type'=>1])->sum('value'); + $map5['user_id'] = $data['id']; $map5['pay_type'] = 1; $map5['create_time'] = $map['create_time']; $spend = M('value_detail_log', 'tab_')->where($map5)->sum('value'); + if(empty($spend)) { $spend = '0.00'; + }else { + $spend = number_format(abs($spend),2,'.',''); } - $map6['user_id'] = $id; + $map6['user_id'] = $data['id']; $map6['pay_type'] = 2; $map6['create_time'] = $map['create_time']; $deposit = M('value_detail_log', 'tab_')->where($map6)->sum('value'); @@ -2572,13 +2573,13 @@ class ExportController extends Controller $promoteCoin = '0.00'; } - $map8['user_id'] = $id; + $map8['user_id'] = $data['id']; $map8['create_time'] = $map['create_time']; - $newValueByTimeDatas = M('value_detail_log', 'tab_')->field('after_value')->where($map8)->group('user_id')->select(); + $newValueByTimeDatas = M('value_detail_log', 'tab_')->field('after_value')->where($map8)->order('create_time desc')->limit(1)->select(); if(empty($newValueByTimeDatas)) { $aValue = '0.00'; }else { - $aValue = $newValueByTimeDatas['after_value']; + $aValue = $newValueByTimeDatas[0]['after_value']; } $allDatas['bind_balance'] = $aValue; $allDatas['spend_amount'] = $spend; @@ -2597,8 +2598,8 @@ class ExportController extends Controller $alldatas1['user_id'] = "汇总(检索时间内所有数据的统计)"; $alldatas1['user_account'] = ""; $alldatas1['bind_balance'] = $banlaceTotal; - $alldatas1['spend_amount'] = $totalSpend; - $alldatas1['deposit_amount'] = $deposit; + $alldatas1['spend_amount'] = abs($totalSpend); + $alldatas1['deposit_amount'] = $deposit1; $alldatas1['coin_amount'] = $promoteCoin; mb_convert_variables('GBK', 'UTF-8', $alldatas1); fputcsv($fp, $alldatas1); @@ -2694,9 +2695,14 @@ class ExportController extends Controller ob_flush(); flush();//必须同时使用 ob_flush() 和flush() 函数来刷新输出缓冲。 } + if($t >= 0 ) { + $fuhao = '+'; + }else { + $fuhao = '-'; + } $alldatas['order_number'] = "汇总(检索时间内所有数据的统计)"; $alldatas['create_time'] = ""; - $alldatas['type'] = ""; + $alldatas['type'] = $fuhao; $alldatas['value'] = $t; $alldatas['after_value'] = $first; diff --git a/Application/Admin/Controller/FinanceController.class.php b/Application/Admin/Controller/FinanceController.class.php index 260744384..619bfacaa 100644 --- a/Application/Admin/Controller/FinanceController.class.php +++ b/Application/Admin/Controller/FinanceController.class.php @@ -1231,6 +1231,8 @@ class FinanceController extends ThinkController $spend = M('value_detail_log', 'tab_')->where($map5)->sum('value'); if(empty($spend)) { $spend = '0.00'; + }else { + $spend = number_format(abs($spend),2,'.',''); } $map6['user_id'] = $id; $map6['pay_type'] = 2; @@ -1268,14 +1270,15 @@ class FinanceController extends ThinkController $allpromoteCoin = empty($promoteCoin) ? '0.00' : number_format($allpromoteCoin,2,'.',''); $map4['create_time'] = $map['create_time']; - $banlace = M('value_detail_log', 'tab_')->field('user_id, after_value')->where($map4)->group('user_id')->select(); + $banlace = M('value_detail_log', 'tab_')->field('user_id, after_value')->where($map4)->order('create_time desc')->limit(1)->select(); $banlaceTotal = '0.00'; foreach($banlace as $k222 => $vvv) { $banlaceTotal += $vvv['after_value']; } $banlaceTotal = number_format($banlaceTotal,2,'.',''); $map['user_id'] = ['in', $ids]; - $newValueByTimeDatas = M('value_detail_log', 'tab_')->field('user_id, after_value')->where($map)->group('user_id')->select(); + $newValueByTimeDatas = M('value_detail_log', 'tab_')->field('user_id, after_value, create_time')->where($map)->order('create_time desc')->limit(1)->select(); + // var_dump($newValueByTimeDatas);die(); foreach ($allDatas as $k => $allData) { $allDatas[$k]['after_value'] = "0.00"; @@ -1297,9 +1300,8 @@ class FinanceController extends ThinkController $this->assign('endtime', $initEndTime); }else { $this->assign('starttime', $_REQUEST['timestart']); - $this->assign('endtime', $_REQUEST['endtime']); + $this->assign('endtime', $_REQUEST['timeend']); } - //var_dump($allDatas);die(); $this->assign('banlaceTotal', $banlaceTotal); $this->assign('total', $totalSpend); $this->assign('deposit', $deposit); @@ -1331,6 +1333,9 @@ class FinanceController extends ThinkController } $total = '0.00'; $t = M('value_detail_log', 'tab_')->where($map)->sum('value'); + if (empty($t)) { + $t = '0.00'; + } $valueDetailDatas = M('value_detail_log', 'tab_')->field('order_number, user_id, before_value, value, after_value, create_time, type, remark, pay_type') ->where($map) ->page($page,$row) @@ -1364,15 +1369,21 @@ class FinanceController extends ThinkController $totalAfterValue = '0.00'; } $total = number_format($total,2,'.',''); - // if($total >= 0 ) { - // $fuhao = '+'; - // }else { - // $fuhao = '-'; - // } + if($t >= 0 ) { + $fuhao = '+'; + }else { + $fuhao = '-'; + } $page = set_pagination($counts,$row); if($page) {$this->assign('_page', $page);} $this->assign('fuhao', $fuhao); - + if(empty($_REQUEST['timestart']) && empty($_REQUEST['timeend']) && empty(I('user_account'))) { + $this->assign('starttime', $initBegTime); + $this->assign('endtime', $initEndTime); + }else { + $this->assign('starttime', $_REQUEST['timestart']); + $this->assign('endtime', $_REQUEST['endtime']); + } $this->assign('total', $t); $this->assign('listdata', $vlaueDetailDatas); $this->assign('totalAfterValue', $totalAfterValue); diff --git a/Application/Admin/View/Finance/definiteDetaile.html b/Application/Admin/View/Finance/definiteDetaile.html index ed67ae874..d907880ea 100644 --- a/Application/Admin/View/Finance/definiteDetaile.html +++ b/Application/Admin/View/Finance/definiteDetaile.html @@ -48,11 +48,11 @@
- -
-
@@ -102,6 +102,7 @@ 汇总(检索时间内所有数据的统计) + {$fuhao}{$fuhao} {$total}{$total} @@ -113,7 +114,7 @@
- 导出 + 导出 {$_page|default=''}
diff --git a/Application/Admin/View/Finance/valueDetail.html b/Application/Admin/View/Finance/valueDetail.html index 2e8eec273..35d34c4cd 100644 --- a/Application/Admin/View/Finance/valueDetail.html +++ b/Application/Admin/View/Finance/valueDetail.html @@ -114,7 +114,7 @@ {$data.deposit_amount} {$data.coin_amount} - 查看详情 + 查看详情 @@ -133,7 +133,7 @@
- 导出 + 导出 {$_page|default=''}