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