|
|
@@ -20,6 +20,11 @@ class MoneyLog Extends Model
|
|
|
const TYPE_INCOME = 1;
|
|
|
const TYPE_EXPENDITURE = 2;
|
|
|
|
|
|
+ const STATUS_HIDDEN= 0; //隐藏
|
|
|
+ const STATUS_NORMAL = 1; //正常
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
//
|
|
|
public function users()
|
|
|
{
|
|
|
@@ -36,13 +41,13 @@ class MoneyLog Extends Model
|
|
|
//按照类型月统计 收入- 支出
|
|
|
public static function getCountMonthBalance(int $user_id = 0, string $time = '')
|
|
|
{
|
|
|
- $income = self::where('type', self::TYPE_INCOME);
|
|
|
+ $income = self::where('type', self::TYPE_INCOME)->where('status', self::STATUS_NORMAL);
|
|
|
if(!empty($user_id) && !empty($time)){
|
|
|
$income = $income->where('user_id', $user_id)->whereMonth('create_date', $time);
|
|
|
}
|
|
|
$income = $income->sum('change');
|
|
|
//支出
|
|
|
- $expenditure = self::where('type', self::TYPE_EXPENDITURE);
|
|
|
+ $expenditure = self::where('type', self::TYPE_EXPENDITURE)->where('status', self::STATUS_NORMAL);
|
|
|
if(!empty($user_id) && !empty($time)){
|
|
|
$expenditure = $expenditure->where('user_id', $user_id)->whereMonth('create_date', $time);
|
|
|
}
|
|
|
@@ -60,13 +65,13 @@ class MoneyLog Extends Model
|
|
|
public static function getCountYearBalance(int $user_id = 0, string $time = '')
|
|
|
|
|
|
{
|
|
|
- $income = self::where('type', self::TYPE_INCOME);
|
|
|
+ $income = self::where('type', self::TYPE_INCOME)->where('status', self::STATUS_NORMAL);
|
|
|
if(!empty($user_id) && !empty($time)){
|
|
|
$income = $income->where('user_id', $user_id)->whereYear('create_date', $time);
|
|
|
}
|
|
|
$income = $income->sum('change');
|
|
|
//支出
|
|
|
- $expenditure = self::where('type', self::TYPE_EXPENDITURE);
|
|
|
+ $expenditure = self::where('type', self::TYPE_EXPENDITURE)->where('status', self::STATUS_NORMAL);
|
|
|
if(!empty($user_id) && !empty($time)){
|
|
|
$expenditure = $expenditure->where('user_id', $user_id)->whereYear('create_date', $time);
|
|
|
}
|