From 7194cd49ae8833b1e699a468458fe1670f447e30 Mon Sep 17 00:00:00 2001 From: sunke <18850253506@163.com> Date: Tue, 17 Mar 2020 17:49:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E5=B8=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/ConsoleController.class.php | 63 +++++++++++++++++++ .../Controller/ExportController.class.php | 21 ++++--- .../Controller/FinanceController.class.php | 32 ++++++---- .../Controller/RepairController.class.php | 3 +- .../Admin/View/Deposit/lists_secord.html | 2 +- .../Admin/View/Finance/definiteDetaile.html | 6 +- 6 files changed, 103 insertions(+), 24 deletions(-) diff --git a/Application/Admin/Controller/ConsoleController.class.php b/Application/Admin/Controller/ConsoleController.class.php index a92ad24fd..9e21324e3 100644 --- a/Application/Admin/Controller/ConsoleController.class.php +++ b/Application/Admin/Controller/ConsoleController.class.php @@ -9,6 +9,7 @@ use Base\Tool\Printer; use Base\Tool\TaskClient; use Base\Service\PromoteService; use GuzzleHttp\Client; +use think\Db; class ConsoleController extends Think { @@ -366,4 +367,66 @@ class ConsoleController extends Think { } } } + + + public function coinRecords() { + $deposit = M('deposit', 'tab_')->field('pay_order_number,user_id,user_account,pay_status,pay_way,pay_amount,create_time as pay_time,2 as record_type')->where(['pay_status'=>1])->select(false); + // $agent = M('agent', 'tab_')->field('pay_order_number,user_id,user_account,pay_status,pay_way,real_amount as pay_amount,create_time as pay_time,3 as record_type')->where(['pay_status'=>1])->select(false); + // $spend = M('spend', 'tab_')->field('pay_order_number,user_id,user_account,pay_status,pay_way,pay_amount,pay_time,1 as record_type')->where(['pay_status' => 1,'pay_way'=>0])->select(false); + $query = M('spend', 'tab_')->field('pay_order_number,user_id,user_account,pay_status,pay_way,pay_amount,pay_time,record_type')->where(['pay_status' => 1,'pay_way'=>0])->union($deposit,'pay_time')->select(false); + + $model = new \Think\Model(); + $datas = $model->table('(' . $query . ') a ')->order('pay_time asc')->select(); + foreach ($datas as $key => $data) { + if(empty($data['pay_order_number'])) { + $order = 0; + }else { + $order = $data['pay_order_number']; + } + $data['order_number'] = $order; + $data['user_id'] = $data['user_id']; + $data['value'] = $data['pay_amount']; + $data['before_value'] = 0; + $data['after_value'] = 0; + $data['create_time'] = $data['pay_time']; + if ($data['record_type'] == 1) { + $data['type'] = 'spend'; + $data['remark'] ='历史消费spend'; + $data['pay_type'] = 1; + $data['value'] = -$data['pay_amount']; + } + if ($data['record_type'] == 2) { + $data['type'] = 'deposit'; + $data['remark'] ='历史充值deposit'; + $data['pay_type'] = 2; + $data['value'] = $data['pay_amount']; + } + + + M('value_detail_log', 'tab_')->add($data); + } + echo "success"; + } + + + public function updateValue() { + //$map['type'] = ['neq', '2']; + $valueDetails = M('value_detail_log', 'tab_')->field('user_id')->where($map)->group('user_id')->select(); + foreach ($valueDetails as $key => $valueDetail) { + $user_id = $valueDetail['user_id']; + $map['user_id'] = $user_id; + $userValues = M('value_detail_log', 'tab_')->where($map)->select(); + $currentValue = 0; + foreach ($userValues as $userValue) { + $id = $userValue['id']; + $userValue['before_value'] = $currentValue; + + $userValue['after_value'] = $currentValue + $userValue['value']; + M('value_detail_log', 'tab_')->where(['id' => $id])->save($userValue); + $after_update = M('value_detail_log', 'tab_')->where(['id'=>$id])->find(); + $currentValue = $after_update['after_value']; + } + } + + } } diff --git a/Application/Admin/Controller/ExportController.class.php b/Application/Admin/Controller/ExportController.class.php index 0c474461a..f72412343 100644 --- a/Application/Admin/Controller/ExportController.class.php +++ b/Application/Admin/Controller/ExportController.class.php @@ -2631,10 +2631,18 @@ class ExportController extends Controller $map['create_time'] = array('elt', (strtotime($_REQUEST['timeend']) + 86399)); } $total = 0; + $t = M('value_detail_log', 'tab_')->where($map)->sum('value'); // $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) // ->select(); + $first = M('value_detail_log', 'tab_')->field('after_value')->where($map)->limit(1)->order('create_time')->select(); + if (!empty($first[0]['after_value'])) { + $first = number_format($first[0]['after_value'],2,'.',''); + }else { + $first = '0.00'; + } + $csvFileName = '平台币明细'.'.csv'; //设置好告诉浏览器要下载excel文件的headers @@ -2665,7 +2673,7 @@ class ExportController extends Controller $vlaueDetailData['create_time'] = date('Y-m-d H:i:s', $valueDetailData['create_time']); if($valueDetailData['pay_type'] == 1) { $vlaueDetailData['type'] = "消费"; - $total -= $valueDetailData['value']; + $total += $valueDetailData['value']; } if($valueDetailData['pay_type'] == 2) { $vlaueDetailData['type'] = "充值"; @@ -2686,16 +2694,11 @@ class ExportController extends Controller ob_flush(); flush();//必须同时使用 ob_flush() 和flush() 函数来刷新输出缓冲。 } - if ($total >= 0) { - $fuhao = '+'; - }else { - $fuhao = '-'; - } $alldatas['order_number'] = "汇总(检索时间内所有数据的统计)"; $alldatas['create_time'] = ""; - $alldatas['type'] = $fuhao; - $alldatas['value'] = $total; - $alldatas['after_value'] = ""; + $alldatas['type'] = ""; + $alldatas['value'] = $t; + $alldatas['after_value'] = $first; mb_convert_variables('GBK', 'UTF-8', $alldatas); fputcsv($fp, $alldatas); diff --git a/Application/Admin/Controller/FinanceController.class.php b/Application/Admin/Controller/FinanceController.class.php index 7d3612a71..260744384 100644 --- a/Application/Admin/Controller/FinanceController.class.php +++ b/Application/Admin/Controller/FinanceController.class.php @@ -1255,16 +1255,17 @@ class FinanceController extends ThinkController $map1['pay_type'] = 1; $totalSpend = M('value_detail_log', 'tab_')->where($map1)->sum('value'); $totalSpend = empty($totalSpend) ? '0.00' : $totalSpend; + $totalSpend = number_format(abs($totalSpend),2,'.',''); $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; + $deposit= empty($deposit) ? '0.00' : number_format($deposit,2,'.',''); $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; + $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(); @@ -1272,7 +1273,7 @@ class FinanceController extends ThinkController 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(); // var_dump($newValueByTimeDatas);die(); @@ -1309,7 +1310,7 @@ class FinanceController extends ThinkController $this->display(); } - public function definiteDetaile() { + public function definiteDetaile($p=1) { $page = intval($p); $page = $page ? $page : 1; //默认显示第一页数据 $row=10; @@ -1328,10 +1329,12 @@ class FinanceController extends ThinkController } elseif (empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) { $map['create_time'] = array('elt', (strtotime($_REQUEST['timeend']) + 86399)); } - $total = 0; + $total = '0.00'; + $t = M('value_detail_log', 'tab_')->where($map)->sum('value'); $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) + ->order('create_time desc') ->select(); $counts = M('value_detail_log', 'tab_')->field('id') ->where($map) @@ -1344,7 +1347,7 @@ class FinanceController extends ThinkController $vlaueDetailDatas[$key]['pay_type'] = $valueDetailData['pay_type']; if($valueDetailData['pay_type'] == 1) { $vlaueDetailDatas[$key]['type'] = "消费"; - $total -= $valueDetailData['value']; + $total += $valueDetailData['value']; } if($valueDetailData['pay_type'] == 2) { $vlaueDetailDatas[$key]['type'] = "充值"; @@ -1355,17 +1358,24 @@ class FinanceController extends ThinkController $total += $valueDetailData['value']; } } - if($total >= 0 ) { - $fuhao = '+'; + if (!empty($vlaueDetailDatas[0]['after_value'])) { + $totalAfterValue = number_format($vlaueDetailDatas[0]['after_value'],2,'.',''); }else { - $fuhao = '-'; - } + $totalAfterValue = '0.00'; + } + $total = number_format($total,2,'.',''); + // if($total >= 0 ) { + // $fuhao = '+'; + // }else { + // $fuhao = '-'; + // } $page = set_pagination($counts,$row); if($page) {$this->assign('_page', $page);} $this->assign('fuhao', $fuhao); - $this->assign('total', $total); + $this->assign('total', $t); $this->assign('listdata', $vlaueDetailDatas); + $this->assign('totalAfterValue', $totalAfterValue); $this->display(); } diff --git a/Application/Admin/Controller/RepairController.class.php b/Application/Admin/Controller/RepairController.class.php index 9f111b602..f6eb96244 100644 --- a/Application/Admin/Controller/RepairController.class.php +++ b/Application/Admin/Controller/RepairController.class.php @@ -149,7 +149,8 @@ class RepairController extends ThinkController { 'pay_order_number' => $orderNo, 'pay_status' => 0 ])->save([ - 'pay_status' => 1 + 'pay_status' => 1, + 'payed_time' => time() ]); if ($r) { diff --git a/Application/Admin/View/Deposit/lists_secord.html b/Application/Admin/View/Deposit/lists_secord.html index 7e534ac61..380119bc6 100644 --- a/Application/Admin/View/Deposit/lists_secord.html +++ b/Application/Admin/View/Deposit/lists_secord.html @@ -118,7 +118,7 @@