|
|
@@ -2,7 +2,7 @@
|
|
|
|
|
|
namespace app\api\controller;
|
|
|
|
|
|
-use app\common\model\StockConfig;
|
|
|
+use DateTime;
|
|
|
use app\common\model\MoneyLog as MonuyModel;
|
|
|
use app\common\model\StockLog;
|
|
|
use think\exception\ValidateException;
|
|
|
@@ -19,15 +19,36 @@ class MoneyLog extends Base
|
|
|
{
|
|
|
|
|
|
$time = $this->request->post('time/s', date('Y-m'));
|
|
|
- $result['count'] = $monuyModel::getCountBalance($this->userinfo['id'], $time);
|
|
|
- $result['list'] = $monuyModel//->where('user_id', $this->userinfo['id'])
|
|
|
+ $result['count'] = $monuyModel::getCountMonthBalance($this->userinfo['id'], $time);
|
|
|
+ $result['list'] = $monuyModel->where('user_id', $this->userinfo['id'])
|
|
|
->whereMonth('create_date', $time)
|
|
|
->order('id desc')
|
|
|
- //->group('create_date')
|
|
|
->paginate(10);
|
|
|
$this->success('ok', $result);
|
|
|
}
|
|
|
|
|
|
+ //记账统计
|
|
|
+ public function getCount(MonuyModel $monuyModel)
|
|
|
+ {
|
|
|
+
|
|
|
+ $type = $this->request->post('type/d, 1');
|
|
|
+ $time = $this->request->post('time/s', date('Y-m'));
|
|
|
+ //月统计
|
|
|
+ if($type == 1){
|
|
|
+ $result = $monuyModel::getCountMonthBalance($this->userinfo['id'], $time);
|
|
|
+ //日均支出
|
|
|
+ $day = getDaysOfMonth($time);
|
|
|
+ $result['day_expenditure'] = ($result['expenditure'] > 0)? bcdiv($result['expenditure'], $day, 2): 0;
|
|
|
+ }else{
|
|
|
+ $result = $monuyModel::getCountYearBalance($this->userinfo['id'], $time);
|
|
|
+ //日均支出
|
|
|
+ $day = getDaysOfYear($time);
|
|
|
+ $result['day_expenditure'] = ($result['expenditure'] > 0)? bcdiv($result['expenditure'], $day, 2): 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success('ok', $result);
|
|
|
+ }
|
|
|
+
|
|
|
//添加记账
|
|
|
public function money(MonuyModel $monuyModel)
|
|
|
{
|