ReportRepository.php
1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
namespace App\Repositories\Business;
use App\Exceptions\Api\ApiException;
use App\Modules\Enums\ErrorCode;
use App\Modules\Models\DayIncome\DayIncome;
use App\Modules\Models\Settlement\Finance;
use App\Modules\Repositories\BaseRepository;
/**
 * Class SpotRepository
 * @package App\Repositories\Spot
 */
class ReportRepository extends BaseRepository
{
    public function getSpotDayIncome($start_date, $end_date, $spot_id)
    {
        $where = [
            ['day', '>=', $start_date],
            ['day', '<=', $end_date],
            ['spot_id', '=', $spot_id],
        ];
        return DayIncome::where($where)->get();
    }
    public function getSpotMonthIncome($start_month, $end_month, $spot_id)
    {
        $where = [
            ['month', '>=', $start_month],
            ['month', '<=', $end_month],
            ['spot_id', '=', $spot_id],
        ];
        return Finance::where($where)->get();
    }
    public function getSpotRentInMonthIncomeTotal($month,$spot_id)
    {
        $month = str_replace('-','',$month);
        $where = [
            ['month', '=', $month],
            ['spot_id', '=', $spot_id],
        ];
        $finance = Finance::where($where)->first();
        if($finance == null){
            throw new ApiException(ErrorCode::FINANCE_NOT_EXIST,trans('api.error.finance_not_exist'));
        }
        return $finance->total;
    }
    public function getSpotGuideInMonthIncomeTotal($month,$spot_id){
        $where = [
            ['month', '=', $month],
            ['spot_id', '=', $spot_id],
        ];
        $finance = Finance::where($where)->first();
        if($finance == null){
            throw new ApiException(ErrorCode::FINANCE_NOT_EXIST,trans('api.error.finance_not_exist'));
        }
        return $finance->guide_total;
    }
}