推广平台>财务管理>结算中心--更新

master
chenxiaojun 5 years ago
parent 43b5038778
commit 118aae4f83

@ -498,7 +498,7 @@ class WithdrawModel extends Model{
{ {
$promoteGameRatioMap['status'] = 1; $promoteGameRatioMap['status'] = 1;
$promoteGameRatioMap['promote_id'] = $promote['id']; $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) ->where($promoteGameRatioMap)
->order('update_time desc') ->order('update_time desc')
->select(); ->select();
@ -566,7 +566,7 @@ class WithdrawModel extends Model{
$promoteGameRatioMap['status'] = 1; $promoteGameRatioMap['status'] = 1;
$promoteGameRatioMap['promote_id'] = $promote['id']; $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) ->where($promoteGameRatioMap)
->order('update_time desc') ->order('update_time desc')
->select(); ->select();

@ -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, $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 >= $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 >= $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(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")
->where($map) ->where($map)
->find(); ->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']; $notWithdrawnAmount = M('withdraw', 'tab_')->field('sum(sum_money) as withdrawn_amount')->where($withdrawMap)->find()['withdrawn_amount'];
$income['withdrawn_amount'] = $income['withdrawn_amount'] ?? '0.00'; $income['withdrawn_amount'] = $income['withdrawn_amount'] ?? '0.00';
$notWithdrawnAmount = $notWithdrawnAmount ?? 0; $notWithdrawnAmount = $notWithdrawnAmount ?? 0;
$income['not_withdrawn_amount'] = bcadd($income['not_withdrawn_amount'], $notWithdrawnAmount, 2); $income['not_withdrawn_amount'] = bcadd($this->getSumAmountBySettlementType(), $notWithdrawnAmount, 2);
$income['not_withdrawn_amount'] = bcadd($income['not_withdrawn_amount'], $this->getNotWithdrawnAmount(), 2);
$withdrawMap['status'] = ['not in', [-2, -1]]; $withdrawMap['status'] = ['not in', [-2, -1]];
$withdrawns = M('withdraw', 'tab_')->field('settlement_begin_time, settlement_end_time') $withdrawns = M('withdraw', 'tab_')->field('settlement_begin_time, settlement_end_time')
@ -207,6 +205,41 @@ class FinanceController extends BaseController
$this->display(); $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() public function getNotWithdrawnAmount()
{ {
$thisMonth = strtotime(date('Y-m')); $thisMonth = strtotime(date('Y-m'));

Loading…
Cancel
Save