@@ -28,6 +28,16 @@ class MoneyLog extends Base
$this->success('ok', $result);
}
+
+ //记账统计每天
+ public function getCountDay(MonuyModel $monuyModel)
+ {
+ $time = $this->request->post('time/s', date('Y-m'));
+ $result = $monuyModel::getCountDayBalance($time);
+ $this->success('ok', $result);
+ }
//记账统计
public function getCount(MonuyModel $monuyModel)
{
@@ -55,6 +55,8 @@ Route::group('user', function () {
Route::rule('getMoneyType','moneyLog/getConfig','POST');
Route::rule('getMoneyCount','MoneyLog/getCount','POST');
+ Route::rule('getMoneyCountDay','MoneyLog/getCountDay','POST');
})->middleware(AllowCrossDomain::class);
@@ -84,4 +84,18 @@ class MoneyLog Extends Model
];
+ //按照类型天统计 收入- 支出
+ public static function getCountDayBalance(string $time = '')
+ $list = self::where('status', self::STATUS_NORMAL)->whereMonth('create_date', $time)
+ ->group('create_date')
+ ->field('create_date, sum(if(type=1,`change`,0)) as income, sum(if(type=2,`change`, 0)) as expenditure')
+ ->select();
+ return $list;