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'));