From 89ea1b75d830b1bba7a59fe45e7ca15417e41b8c Mon Sep 17 00:00:00 2001 From: Regend Soh <17229500+regendsoh@users.noreply.github.com> Date: Tue, 24 Sep 2019 21:37:08 +0800 Subject: [PATCH] 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 --- app/Models/User.php | 25 +++++++++++++++++++ resources/views/material/admin/code/index.tpl | 7 ++++++ 2 files changed, 32 insertions(+) diff --git a/app/Models/User.php b/app/Models/User.php index 14915cec..517cb8b5 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -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); + } } diff --git a/resources/views/material/admin/code/index.tpl b/resources/views/material/admin/code/index.tpl index ef800f48..f10478d4 100644 --- a/resources/views/material/admin/code/index.tpl +++ b/resources/views/material/admin/code/index.tpl @@ -15,6 +15,13 @@

系统中金额流转记录。

+

+ 今日流水:¥{$user->todayIncome()}
+ 昨日流水:¥{$user->yesterdayIncome()}
+ 这月流水:¥{$user->thisMonthIncome()}
+ 上月流水:¥{$user->lastMonthIncome()}
+ 总共流水:¥{$user->totalIncome()} +

显示表项: {include file='table/checkbox.tpl'}