diff --git a/Application/Admin/Controller/ExportController.class.php b/Application/Admin/Controller/ExportController.class.php index 2d48c4a3c..de98b3833 100644 --- a/Application/Admin/Controller/ExportController.class.php +++ b/Application/Admin/Controller/ExportController.class.php @@ -2475,7 +2475,7 @@ class ExportController extends Controller break; case 28: $xlsCell = array( - "账号ID","玩家账号", "账户平台币", "累计使用平台币", "累计充值平台币", "后台发放平台币" + "账号ID","玩家账号", "平台币余额", "平台币直充余额", "平台币直充支出", "平台币直充金额", "后台发放平台币" ); $params = I('get.'); @@ -2545,54 +2545,82 @@ class ExportController extends Controller ->field('id, account') ->where($map) ->count(); - + $perSize = 1000;//每次查询的条数 $pages = ceil($count / $perSize); for($i = 1; $i <= $pages; $i++) { - $datas = M('user', 'tab_') - ->field('id, account') - ->where($map) - ->limit(($i-1)*$perSize ,$perSize) - ->select(); + // $datas = M('user', 'tab_') + // ->field('id, account') + // ->where($map) + // ->limit(($i-1)*$perSize ,$perSize) + // ->select(); + $map5['v.pay_type'] = 1; + $map5['v.create_time'] = $map['create_time']; + $map5[] = ['u.id = v.user_id'] ; + + $map6[] = ['u.id = v.user_id']; + $map6['v.pay_type'] = 2; + $map6['v.create_time'] = $map['create_time']; + + $map7[] = ['u.id = v.user_id']; + $map7['v.pay_type'] = 3; + $map7['v.create_time'] = $map['create_time']; + + $map8[] = ['u.id = v.user_id']; + $map8['v.create_time'] = $map['create_time']; + + $valueQuery5 = M('value_detail_log', 'tab_')->alias('v')->field('sum(abs(v.value)) as spend_value') + ->where($map5)->buildSql(); + $valueQuery6 = M('value_detail_log', 'tab_')->alias('v')->field('sum(v.value) as spend_value') + ->where($map6)->buildSql(); + $valueQuery7 = M('value_detail_log', 'tab_')->alias('v')->field('sum(v.value) as spend_value') + ->where($map7)->buildSql(); + $valueQuery8 = M('value_detail_log', 'tab_')->alias('v')->field('after_value')->where($map8)->order('create_time desc')->limit(1)->buildSql(); + $datas = M('user', 'tab_')->alias('u')->field("u.id, u.account, {$valueQuery8} as totalvalue, {$valueQuery5} as spendvalue, {$valueQuery6} as deposit, {$valueQuery7} as promoteCoin , if (({$valueQuery6}) - ({$valueQuery5}) > 0, ({$valueQuery6}) - ({$valueQuery5}), 0) as restvalue")->where($map)->limit(($i-1)*$perSize ,$perSize)->order('restvalue desc')->group('u.id')->select(); + $query = M('user', 'tab_')->alias('u')->field("u.id, u.account, {$valueQuery8} as totalvalue, {$valueQuery5} as spendvalue, {$valueQuery6} as deposit, {$valueQuery7} as promoteCoin , if (({$valueQuery6}) - ({$valueQuery5}) > 0, ({$valueQuery6}) - ({$valueQuery5}), 0) as restvalue")->where($map)->order('id desc')->group('u.id')->buildSql(); + $allTotalValue1 = M()->alias('t')->table($query)->sum('t.totalvalue'); + $allRestValue = M()->alias('rest')->table($query)->sum('rest.restvalue'); $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'=>$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'); - + // $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'); + $spend = $data['spendvalue']; if(empty($spend)) { $spend = '0.00'; }else { $spend = number_format(abs($spend),2,'.',''); } - $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'); + // $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'); + $deposit = $data['deposit']; if(empty($deposit)) { $deposit = '0.00'; } - $map7['user_id'] = $id; - $map7['pay_type'] = 3; - $map7['create_time'] = $map['create_time']; - $promoteCoin = M('value_detail_log', 'tab_')->where($map7)->sum('value'); + // $map7['user_id'] = $id; + // $map7['pay_type'] = 3; + // $map7['create_time'] = $map['create_time']; + // $promoteCoin = M('value_detail_log', 'tab_')->where($map7)->sum('value'); + $promoteCoin = $data['promoteCoin']; if(empty($promoteCoin)) { $promoteCoin = '0.00'; } - - $map8['user_id'] = $data['id']; - $map8['create_time'] = $map['create_time']; - $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[0]['after_value']; + $restValue = $data['restvalue']; + if(empty($restValue)) { + $restValue = '0.00'; + } + $alltotalvalue = $data['totalvalue']; + if(empty($alltotalvalue)) { + $alltotalvalue = '0.00'; } - $allDatas['bind_balance'] = $aValue; + $allDatas['bind_balance'] = $alltotalvalue; + $allDatas['rest_value'] = $restValue ; $allDatas['spend_amount'] = $spend; $allDatas['deposit_amount'] = $deposit; $allDatas['coin_amount'] = $promoteCoin; @@ -2608,7 +2636,8 @@ class ExportController extends Controller } $alldatas1['user_id'] = "汇总(检索时间内所有数据的统计)"; $alldatas1['user_account'] = ""; - $alldatas1['bind_balance'] = $banlaceTotal; + $alldatas1['bind_balance'] = $allTotalValue1; + $alldatas1['restvalue'] = $allRestValue; $alldatas1['spend_amount'] = abs($totalSpend); $alldatas1['deposit_amount'] = $deposit1; $alldatas1['coin_amount'] = $promoteCoin; diff --git a/Application/Admin/Controller/FinanceController.class.php b/Application/Admin/Controller/FinanceController.class.php index 2cc34b08d..8bf6417c7 100644 --- a/Application/Admin/Controller/FinanceController.class.php +++ b/Application/Admin/Controller/FinanceController.class.php @@ -1305,6 +1305,13 @@ class FinanceController extends ThinkController if ($sort == 12) { $order = 'id desc'; } + + if ($sort == 16) { + $order = 'restvalue desc'; + } + if ($sort == 17) { + $order = 'restvalue asc'; + } $this->assign('sorting', $sort); $map5['v.pay_type'] = 1; $map5['v.create_time'] = $map['create_time']; @@ -1318,14 +1325,21 @@ class FinanceController extends ThinkController $map7['v.pay_type'] = 3; $map7['v.create_time'] = $map['create_time']; + $map8[] = ['u.id = v.user_id']; + $map8['v.create_time'] = $map['create_time']; + $valueQuery5 = M('value_detail_log', 'tab_')->alias('v')->field('sum(abs(v.value)) as spend_value') ->where($map5)->buildSql(); $valueQuery6 = M('value_detail_log', 'tab_')->alias('v')->field('sum(v.value) as spend_value') ->where($map6)->buildSql(); $valueQuery7 = M('value_detail_log', 'tab_')->alias('v')->field('sum(v.value) as spend_value') ->where($map7)->buildSql(); - - $datas = M('user', 'tab_')->alias('u')->field("u.id, u.account, {$valueQuery5} as spendvalue, {$valueQuery6} as deposit, {$valueQuery7} as promoteCoin")->where($map0)->page($page,$row)->order($order)->group('u.id')->select(); + $valueQuery8 = M('value_detail_log', 'tab_')->alias('v')->field('after_value')->where($map8)->order('create_time desc')->limit(1)->buildSql(); + $datas = M('user', 'tab_')->alias('u')->field("u.id, u.account, {$valueQuery8} as totalvalue, {$valueQuery5} as spendvalue, {$valueQuery6} as deposit, {$valueQuery7} as promoteCoin , if (({$valueQuery6}) - ({$valueQuery5}) > 0, ({$valueQuery6}) - ({$valueQuery5}), 0) as restvalue")->where($map0)->page($page,$row)->order($order)->group('u.id')->select(); + $query = M('user', 'tab_')->alias('u')->field("u.id, u.account, {$valueQuery8} as totalvalue, {$valueQuery5} as spendvalue, {$valueQuery6} as deposit, {$valueQuery7} as promoteCoin , if (({$valueQuery6}) - ({$valueQuery5}) > 0, ({$valueQuery6}) - ({$valueQuery5}), 0) as restvalue")->where($map0)->order($order)->group('u.id')->buildSql(); + $allTotalValue1 = M()->alias('t')->table($query)->sum('t.totalvalue'); + $allRestValue = M()->alias('rest')->table($query)->sum('rest.restvalue'); + // var_dump($datas);die(); // $datas = M('user', 'tab_') // ->field('id, account') @@ -1333,7 +1347,7 @@ class FinanceController extends ThinkController // ->page($page,$row) // ->order('id desc') // ->select(); - + $count = M('user', 'tab_') ->field('id, account') ->where($map) @@ -1348,38 +1362,31 @@ class FinanceController extends ThinkController $account = $data['account']; $allDatas[$key]['user_id'] = $id; $allDatas[$key]['user_account'] = $account; - // $map5['user_id'] = $id; - // $map5['pay_type'] = 1; - // $map5['create_time'] = $map['create_time']; - // $spend = M('value_detail_log', 'tab_')->where($map5)->sum('value'); - $spend = $data['spendvalue']; + $spend = $data['spendvalue']; if(empty($spend)) { $spend = '0.00'; }else { $spend = number_format(abs($spend),2,'.',''); } - // $map6['user_id'] = $id; - // $map6['pay_type'] = 2; - // $map6['create_time'] = $map['create_time']; - // $deposit = M('value_detail_log', 'tab_')->where($map6)->sum('value'); $deposit = $data['deposit']; if(empty($deposit)) { $deposit = '0.00'; } - // $map7['user_id'] = $id; - // $map7['pay_type'] = 3; - // $map7['create_time'] = $map['create_time']; - // $promoteCoin = M('value_detail_log', 'tab_')->where($map7)->sum('value'); $promoteCoin = $data['promoteCoin']; if(empty($promoteCoin)) { $promoteCoin = '0.00'; } - $restValue = $data['restValue']; + $restValue = $data['restvalue']; if(empty($restValue)) { $restValue = '0.00'; } + $alltotalvalue = $data['totalvalue']; + if(empty($alltotalvalue)) { + $alltotalvalue = '0.00'; + } // $allDatas[$key]['bind_balance'] = $bind_balance; - $allDatas[$key]['rest_value'] = $deposit - $spend ; + $allDatas[$key]['after_value'] = $alltotalvalue ; + $allDatas[$key]['rest_value'] = $restValue ; $allDatas[$key]['spend_amount'] = $spend; $allDatas[$key]['deposit_amount'] = $deposit; $allDatas[$key]['coin_amount'] = $promoteCoin; @@ -1406,28 +1413,28 @@ class FinanceController extends ThinkController }else { $banlace = M('value_detail_log', 'tab_')->field('user_id, after_value')->where($map4)->order('create_time desc')->select(); } - $banlaceTotal = '0.00'; - foreach($banlace as $k222 => $vvv) { - $banlaceTotal += $vvv['after_value']; - } - $banlaceTotal = number_format($banlaceTotal,2,'.',''); + // $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, create_time')->where($map)->order('create_time desc')->limit(1)->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); + // // var_dump($newValueByTimeDatas);die(); + // foreach ($allDatas as $k => $allData) { + // $allDatas[$k]['after_value'] = "0.00"; + // foreach ($newValueByTimeDatas as $key1 => $newValueByTimeData ) { + // if (intval($allData['user_id']) == intval($newValueByTimeData['user_id'])) { + // $allDatas[$k]['after_value'] = $newValueByTimeData['after_value']; + // break; + // }else { + // $allDatas[$k]['after_value'] = "0.00"; - // var_dump($newValueByTimeDatas);die(); - foreach ($allDatas as $k => $allData) { - $allDatas[$k]['after_value'] = "0.00"; - foreach ($newValueByTimeDatas as $key1 => $newValueByTimeData ) { - if (intval($allData['user_id']) == intval($newValueByTimeData['user_id'])) { - $allDatas[$k]['after_value'] = $newValueByTimeData['after_value']; - break; - }else { - $allDatas[$k]['after_value'] = "0.00"; - - } - } + // } + // } - } + // } $page = set_pagination($count,$row); if($page) {$this->assign('_page', $page);} if(empty($_REQUEST['timestart']) && empty($_REQUEST['timeend']) && empty(I('user_account'))) { @@ -1437,12 +1444,12 @@ class FinanceController extends ThinkController $this->assign('starttime', $_REQUEST['timestart']); $this->assign('endtime', $_REQUEST['timeend']); } - $this->assign('banlaceTotal', $banlaceTotal); + $this->assign('banlaceTotal', $allTotalValue1); $this->assign('total', $totalSpend); $this->assign('deposit', $deposit); $this->assign('promoteCoin', $allpromoteCoin); $this->assign('data', $allDatas); - + $this->assign('resttotal', $allRestValue); $this->display(); } diff --git a/Application/Admin/View/Finance/valueDetail.html b/Application/Admin/View/Finance/valueDetail.html index 52cdbcf63..5676265e4 100644 --- a/Application/Admin/View/Finance/valueDetail.html +++ b/Application/Admin/View/Finance/valueDetail.html @@ -93,45 +93,53 @@ - 账号ID + 账号ID▭ 账号ID 账号ID - 账号ID + 账号ID▭ 玩家账号 平台币余额 - 平台币直充余额 - 平台币直充支出 + 平台币直充余额▭ + + 平台币直充余额 + + 平台币直充余额 + + 平台币直充余额▭ + + + 平台币直充支出▭ 平台币直充支出 平台币直充支出 - 平台币直充支出 + 平台币直充支出▭ - 平台币直充金额 + 平台币直充金额▭ 平台币直充金额 平台币直充金额 - 平台币直充金额 + 平台币直充金额▭ - 后台发放平台币 + 后台发放平台币▭ 后台发放平台币 后台发放平台币 - 后台发放平台币 + 后台发放平台币▭ 操作 @@ -161,6 +169,7 @@ 汇总(检索时间内所有数据的统计) {$banlaceTotal} + {$resttotal} {$total} {$deposit} {$promoteCoin} @@ -468,6 +477,18 @@ document.getElementById('sort').value = 9 document.getElementById('search').click(); } + if (status == 16) { + document.getElementById('sort').value = 16 + document.getElementById('search').click(); + } + if (status == 17) { + document.getElementById('sort').value = 17 + document.getElementById('search').click(); + } + if (status == 18) { + document.getElementById('sort').value = 16 + document.getElementById('search').click(); + }