From 118aae4f8313fe9fdc6d4cd924113f7c0533adc6 Mon Sep 17 00:00:00 2001 From: chenxiaojun <956334972@qq.com> Date: Wed, 19 Feb 2020 19:43:47 +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--=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/Model/WithdrawModel.class.php | 4 +- .../Controller/FinanceController.class.php | 41 +++++++++++++++++-- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/Application/Admin/Model/WithdrawModel.class.php b/Application/Admin/Model/WithdrawModel.class.php index 75b82fb75..a591165cb 100644 --- a/Application/Admin/Model/WithdrawModel.class.php +++ b/Application/Admin/Model/WithdrawModel.class.php @@ -498,7 +498,7 @@ class WithdrawModel extends Model{ { $promoteGameRatioMap['status'] = 1; $promoteGameRatioMap['promote_id'] = $promote['id']; - $promoteGameRatios = D('promote_game_ratio')->field('game_id, ratio, turnover_ratio, begin_time, end_time') + $promoteGameRatios = M('promote_game_ratio', 'tab_')->field('game_id, ratio, turnover_ratio, begin_time, end_time') ->where($promoteGameRatioMap) ->order('update_time desc') ->select(); @@ -566,7 +566,7 @@ class WithdrawModel extends Model{ $promoteGameRatioMap['status'] = 1; $promoteGameRatioMap['promote_id'] = $promote['id']; - $promoteGameRatios = D('promote_game_ratio')->field('game_id, ratio, turnover_ratio, begin_time, end_time') + $promoteGameRatios = M('promote_game_ratio', 'tab_')->field('game_id, ratio, turnover_ratio, begin_time, end_time') ->where($promoteGameRatioMap) ->order('update_time desc') ->select(); diff --git a/Application/Home/Controller/FinanceController.class.php b/Application/Home/Controller/FinanceController.class.php index c42acad92..dd031d65c 100644 --- a/Application/Home/Controller/FinanceController.class.php +++ b/Application/Home/Controller/FinanceController.class.php @@ -130,8 +130,7 @@ class FinanceController extends BaseController $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, - sum(if(selle_status = 0, pay_amount * selle_ratio, 0)) as not_withdrawn_amount") + sum(if(pay_time < $thisDay, if(selle_status = 0, pay_amount * selle_ratio, 0), 0)) as balance") ->where($map) ->find(); @@ -148,8 +147,7 @@ class FinanceController extends BaseController $notWithdrawnAmount = M('withdraw', 'tab_')->field('sum(sum_money) as withdrawn_amount')->where($withdrawMap)->find()['withdrawn_amount']; $income['withdrawn_amount'] = $income['withdrawn_amount'] ?? '0.00'; $notWithdrawnAmount = $notWithdrawnAmount ?? 0; - $income['not_withdrawn_amount'] = bcadd($income['not_withdrawn_amount'], $notWithdrawnAmount, 2); - $income['not_withdrawn_amount'] = bcadd($income['not_withdrawn_amount'], $this->getNotWithdrawnAmount(), 2); + $income['not_withdrawn_amount'] = bcadd($this->getSumAmountBySettlementType(), $notWithdrawnAmount, 2); $withdrawMap['status'] = ['not in', [-2, -1]]; $withdrawns = M('withdraw', 'tab_')->field('settlement_begin_time, settlement_end_time') @@ -207,6 +205,41 @@ class FinanceController extends BaseController $this->display(); } + public function getSumAmountBySettlementType() + { + $withdrawModel = new WithdrawModel(); + $balance = 0; + + if ($this->loginPromote['settlement_type'] == 2) { + $settlementType = 2; + } else { + $map['pay_status'] = 1; + $map['selle_status'] = 0; + $balance = M('spend', 'tab_')->field('sum(pay_amount * selle_ratio) as balance')->where($map)->find()['balance']; + $balance = $balance ? bcdiv($balance , 100, 2) : 0; + $settlementType = 3; + } + + $months = $this->getDayList(strtotime('2019-09'), strtotime(date('Y-m')), 2); + $promote = $this->loginPromote; + + if ($settlementType == 2) { + $fun = 'getMonthAmount'; + } else { + $fun = 'getRecoupAmount'; + } + + if ($months) { + foreach ($months as $month) { + $data['begin_time'] = strtotime($month); + $data['end_time'] = strtotime('+1 month', $data['begin_time']) - 1; + $balance = bcadd($balance, $withdrawModel->$fun($promote, $data)); + } + } + + return $balance; + } + public function getNotWithdrawnAmount() { $thisMonth = strtotime(date('Y-m'));