feat: add display income feature (#813)

* Adding income calculation function

Below functions are added:
- yesterday_income()
- today_income()
- this_month_income()
- last_month_income()
- total_income()

* Add income display on /admin/code page

Display the following information at /admin/code
- Today's income
- Yesterday's income
- This month's income
- Last month's income
- Total income

* Reformatting code style

Reformat the code, attempting to follow the standard required.

* Refactor to camel case naming

* Refactor to camel case naming

* Reformat due to spacing and tabbing issue
dev
Regend Soh 7 years ago committed by Anankke
parent 797bd35f1b
commit 89ea1b75d8

@ -353,4 +353,29 @@ class User extends Model
}
return round($top_up, 2);
}
public function yesterdayIncome()
{
return Code::where('usedatetime','like',date('Y-m-d%',strtotime("-1 days")))->sum(number);
}
public function todayIncome()
{
return Code::where('usedatetime','like',date('Y-m-d%'))->sum(number);
}
public function thisMonthIncome()
{
return Code::where('usedatetime','like',date('Y-m%'))->sum(number);
}
public function lastMonthIncome()
{
return Code::where('usedatetime','like',date('Y-m%',strtotime("-1 months")))->sum(number);
}
public function totalIncome()
{
return Code::where('usedatetime','like',date('%'))->sum(number);
}
}

@ -15,6 +15,13 @@
<div class="card-main">
<div class="card-inner">
<p>系统中金额流转记录。</p>
<p>
今日流水:¥{$user->todayIncome()}<br/>
昨日流水:¥{$user->yesterdayIncome()}<br/>
这月流水:¥{$user->thisMonthIncome()}<br/>
上月流水:¥{$user->lastMonthIncome()}<br/>
总共流水:¥{$user->totalIncome()}
</p>
<p>显示表项:
{include file='table/checkbox.tpl'}
</p>

Loading…
Cancel
Save