From 669e641c1ee8402955bd99b83067e8ceb75c93bf Mon Sep 17 00:00:00 2001 From: chenxiaojun <956334972@qq.com> Date: Sat, 9 Nov 2019 16:23:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A8=E5=B9=BF=E5=B9=B3=E5=8F=B0->=E8=B4=A2?= =?UTF-8?q?=E5=8A=A1=E7=AE=A1=E7=90=86->(=E7=BB=93=E7=AE=97=E4=B8=AD?= =?UTF-8?q?=E5=BF=83|=E7=BB=93=E7=AE=97=E6=98=8E=E7=BB=86--=E6=A3=80?= =?UTF-8?q?=E7=B4=A2=E6=97=A5=E6=9C=9F=E8=8C=83=E5=9B=B4=E8=B0=83=E6=95=B4?= =?UTF-8?q?)(=E6=8F=90=E7=8E=B0=E8=AE=B0=E5=BD=95->=E7=BB=93=E7=AE=97?= =?UTF-8?q?=E5=8D=95--=E4=BE=A7=E8=BE=B9=E6=A0=8F=E9=AB=98=E4=BA=AE?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/FinanceController.class.php | 161 +++++++++--------- .../Home/View/default/Finance/index.html | 2 +- .../View/default/Finance/settlementDtl.html | 14 +- .../View/default/Public/promote_base.html | 2 +- 4 files changed, 94 insertions(+), 85 deletions(-) diff --git a/Application/Home/Controller/FinanceController.class.php b/Application/Home/Controller/FinanceController.class.php index 1fd08d16f..d2a4a626d 100644 --- a/Application/Home/Controller/FinanceController.class.php +++ b/Application/Home/Controller/FinanceController.class.php @@ -97,40 +97,44 @@ class FinanceController extends BaseController $endTime = strtotime($initEndTime); $endTime = $endTime + 3600 * 24; - $map['chain'] = ['like', $this->loginPromote['chain'] . $this->loginPromote['id'] . '/%']; - $promoteIds = M('promote', 'tab_')->where($map)->getField('id', true); - $promoteIds[] = $this->loginPromote['id']; - $promoteIds = implode(',', $promoteIds); - - $map = []; - $map['pay_status'] = 1; - $map['promote_id'] = ['in', $promoteIds]; - $income = $model->field("sum(if(pay_time < $thisDay, if(selle_ratio > 0, pay_amount * selle_ratio, 0), 0)) as history_income, + $records = []; + $income = []; + if (intval($endTime - $begTime) / (24 * 3600) <= 31) { + $map['chain'] = ['like', $this->loginPromote['chain'] . $this->loginPromote['id'] . '/%']; + $promoteIds = M('promote', 'tab_')->where($map)->getField('id', true); + $promoteIds[] = $this->loginPromote['id']; + $promoteIds = implode(',', $promoteIds); + + $map = []; + $map['pay_status'] = 1; + $map['promote_id'] = ['in', $promoteIds]; + $income = $model->field("sum(if(pay_time < $thisDay, if(selle_ratio > 0, pay_amount * selle_ratio, 0), 0)) as history_income, sum(if(pay_time >= $thisMonth, if(selle_ratio > 0, pay_amount * selle_ratio, 0), 0)) as this_month_income, sum(if((pay_time >= $yesterday and pay_time < $thisDay), if(selle_ratio > 0, pay_amount * selle_ratio, 0), 0)) as yesterday_income, sum(if(pay_time < $thisDay, if(selle_status = 0, pay_amount * selle_ratio, 0), 0)) as balance") - ->where($map) - ->find(); + ->where($map) + ->find(); - foreach ($income as &$value) { - $value = bcdiv($value, 100, 2); - } + foreach ($income as &$value) { + $value = bcdiv($value, 100, 2); + } - $map['pay_time'] = ['between', [$begTime, $endTime]]; - $dayList = $this->getDayList($begTime, $endTime); - $data = $model->field('FROM_UNIXTIME(pay_time, "%Y-%m-%d") as day, + $map['pay_time'] = ['between', [$begTime, $endTime]]; + $dayList = $this->getDayList($begTime, $endTime); + $data = $model->field('FROM_UNIXTIME(pay_time, "%Y-%m-%d") as day, sum(if(selle_ratio > 0, pay_amount * selle_ratio, 0)) as income') - ->where($map) - ->group('day') - ->select(); - $data = $this->assembleRecords($data, $dayList, 'income'); - foreach ($dayList as $day) { - $date = date('Ymd', strtotime($day)); - $records[] = [ - 'day' => $date, - 'income' => bcdiv($data[$day], 100, 2), - 'url' => U('settlementDtl', array('begtime' => $day, 'endtime' => $day)) - ]; + ->where($map) + ->group('day') + ->select(); + $data = $this->assembleRecords($data, $dayList, 'income'); + foreach ($dayList as $day) { + $date = date('Ymd', strtotime($day)); + $records[] = [ + 'day' => $date, + 'income' => bcdiv($data[$day], 100, 2), + 'url' => U('settlementDtl', array('begtime' => $day, 'endtime' => $day)) + ]; + } } $this->assign('income', $income); @@ -164,6 +168,7 @@ class FinanceController extends BaseController $initEndTime = empty(I('endtime')) ? $initEndTime : I('endtime'); $begTime = strtotime($initBegTime); $endTime = strtotime($initEndTime); + $endTime += 3600 * 24; $parameter['p'] = $page; $parameter['row'] = $row; @@ -171,63 +176,61 @@ class FinanceController extends BaseController $parameter['begtime'] = $initBegTime; $parameter['endtime'] = $initEndTime; - $map['chain'] = ['like', $this->loginPromote['chain'] . $this->loginPromote['id'] . '/%']; - $ids = M('promote', 'tab_')->where($map)->getField('id', true); - $ids[] = $this->loginPromote['id']; - $ids = implode(',', $ids); - - $map = []; - $map['promote_id'] = ['in', $ids]; - if (!empty($payOrderNumber)) { - $map['pay_order_number'] = $payOrderNumber; - } - if (!empty($begTime) && empty($endTime)) { - $map['pay_time'] = ['egt', $begTime]; - } elseif (empty($begTime) && !empty($endTime)) { - $map['pay_time'] = ['elt', $endTime + 86399]; - } elseif (!empty($begTime) && !empty($endTime)) { - $map['pay_time'] = ['between', [$begTime, $endTime + 86399]]; - } - - $data = $model->field('pay_order_number,game_name,user_account,promote_account,pay_amount,pay_way,if(selle_ratio >= 0,selle_ratio,0) as selle_ratio,pay_time,selle_status,pay_status,withdraw_id') - ->where($map) - ->order('id desc') - ->page($page, $row) - ->select(); - $count = $model->where($map)->count(); - - //提现状态 - $withdrawIds = [0]; - foreach ($data as $key => $value) { - if ($value['withdraw_id'] > 0 && !in_array($value['withdraw_id'], $withdrawIds)) { - $withdrawIds[] = $value['withdraw_id']; + $data = []; + $count = 0; + if (intval($endTime - $begTime) / (24 * 3600) <= 31) { + $map['chain'] = ['like', $this->loginPromote['chain'] . $this->loginPromote['id'] . '/%']; + $ids = M('promote', 'tab_')->where($map)->getField('id', true); + $ids[] = $this->loginPromote['id']; + $ids = implode(',', $ids); + + $map = []; + $map['promote_id'] = ['in', $ids]; + $map['pay_time'] = ['between', [$begTime, $endTime]]; + if (!empty($payOrderNumber)) { + $map['pay_order_number'] = $payOrderNumber; } - } - $withdrawStatus = M('withdraw', 'tab_') - ->where(array('id' => ['in', $withdrawIds])) - ->getField('id,status'); - foreach ($data as &$list) { + $data = $model->field('pay_order_number,game_name,user_account,promote_account,pay_amount,pay_way,if(selle_ratio >= 0,selle_ratio,0) as selle_ratio,pay_time,selle_status,pay_status,withdraw_id') + ->where($map) + ->order('id desc') + ->page($page, $row) + ->select(); + $count = $model->where($map)->count(); + //提现状态 - if ($list['pay_status'] == 1) { - switch ($list['selle_status']) { - case 0: - $list['selle_status'] = '未提现'; - break; - default: - if ($list['withdraw_id'] > 0) { - $list['selle_status'] = FinanceController::$withdrawStatus[$withdrawStatus[$list['withdraw_id']]]; - } else { - $list['selle_status'] = ''; - } - break; + $withdrawIds = [0]; + foreach ($data as $key => $value) { + if ($value['withdraw_id'] > 0 && !in_array($value['withdraw_id'], $withdrawIds)) { + $withdrawIds[] = $value['withdraw_id']; } - } else { - $list['selle_status'] = '支付失败'; } + $withdrawStatus = M('withdraw', 'tab_') + ->where(array('id' => ['in', $withdrawIds])) + ->getField('id,status'); - $list['income'] = bcmul($list['pay_amount'], bcdiv($list['selle_ratio'], 100, 2), 2); - $list['pay_time'] = date('Y-m-d H:i:s', $list['pay_time']); + foreach ($data as &$list) { + //提现状态 + if ($list['pay_status'] == 1) { + switch ($list['selle_status']) { + case 0: + $list['selle_status'] = '未提现'; + break; + default: + if ($list['withdraw_id'] > 0) { + $list['selle_status'] = FinanceController::$withdrawStatus[$withdrawStatus[$list['withdraw_id']]]; + } else { + $list['selle_status'] = ''; + } + break; + } + } else { + $list['selle_status'] = '支付失败'; + } + + $list['income'] = bcmul($list['pay_amount'], bcdiv($list['selle_ratio'], 100, 2), 2); + $list['pay_time'] = date('Y-m-d H:i:s', $list['pay_time']); + } } $page = set_pagination($count, $row, $parameter); diff --git a/Application/Home/View/default/Finance/index.html b/Application/Home/View/default/Finance/index.html index 8e6dd89a6..3b5158da2 100644 --- a/Application/Home/View/default/Finance/index.html +++ b/Application/Home/View/default/Finance/index.html @@ -126,7 +126,7 @@ layer.msg('开始时间必须小于等于结束时间', {icon: 5}); return false; } - if ((edate - sdate) > 2505600) { + if ((edate - sdate) > 2592000) { layer.msg('时间间隔不能超过30天,请重新选择日期', {icon: 5}); return false; } diff --git a/Application/Home/View/default/Finance/settlementDtl.html b/Application/Home/View/default/Finance/settlementDtl.html index cd834f78f..b38ea9876 100644 --- a/Application/Home/View/default/Finance/settlementDtl.html +++ b/Application/Home/View/default/Finance/settlementDtl.html @@ -210,12 +210,18 @@ }); $('#submit').click(function () { - var sdate = $('#sdate').val(); - var edate = $('#edate').val(); - if (Date.parse(sdate) > Date.parse(edate)) { - layer.msg('开始时间必须小于等于结束时间'); + var sdate = Date.parse($('#sdate').val()) / 1000; + var edate = Date.parse($('#edate').val()) / 1000; + + if (sdate > edate) { + layer.msg('开始时间必须小于等于结束时间', {icon: 5}); + return false; + } + if ((edate - sdate) > 2592000) { + layer.msg('时间间隔不能超过30天,请重新选择日期', {icon: 5}); return false; } + var url = $(this).attr('url'); console.log(url); var query = $('.jssearch').find('input').serialize(); diff --git a/Application/Home/View/default/Public/promote_base.html b/Application/Home/View/default/Public/promote_base.html index 0c2687b6f..97d8cf52b 100644 --- a/Application/Home/View/default/Public/promote_base.html +++ b/Application/Home/View/default/Public/promote_base.html @@ -73,7 +73,7 @@