GuideRepository.php
2.17 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
72
73
74
75
76
77
<?php
namespace App\Repositories\Business;
use App\Modules\Models\GuideRecord\GuideRecord;
use App\Modules\Repositories\BaseRepository;
/**
* Class SpotRepository
* @package App\Repositories\Spot
*/
class GuideRepository extends BaseRepository
{
public function getSpotGuideRecord($spot_id, $page, $limit, $search)
{
$where = [
['spot_id', '=', $spot_id],
['is_pay', '=', 1]
];
if (isset($search['day'])) {
$where[] = ['pay_time', '>=', $search['day'] . ' 00:00:00'];
$where[] = ['pay_time', '<=', $search['day'] . ' 23:59:59'];
}
if (isset($search['month'])) {
$start_time = $search['month'] . '-01 00:00:00';
$end_time = date('Y-m', strtotime("+1 month {$search['month']}")) . '-01 00:00:00';
$where[] = ['pay_time', '>=', $start_time];
$where[] = ['pay_time', '<=', $end_time];
}
return GuideRecord::where($where)->orderBy('pay_time', 'desc')->skip($page * $limit)->take($limit)->get();
}
public function getTodayIncome($spot_id)
{
$start_time = date('Y-m-d') . ' 00:00:00';
$end_time = date('Y-m-d') . ' 23:59:59';
$where = [
['is_pay', '=', 1],
['spot_id', '=', $spot_id],
['pay_time', '>', $start_time],
['pay_time', '<=', $end_time],
];
$rent_total = GuideRecord::where($where)->sum('real_total');
return $rent_total;
}
public function getThisMonthIncome($spot_id)
{
$time = date('Y-m', time());
$start_time = $time . '-01 00:00:00';
$end_time = date('Y-m-d H:i:s');
$where = [
['is_pay', '=', 1],
['spot_id', '=', $spot_id],
['pay_time', '>', $start_time],
['pay_time', '<=', $end_time],
];
$rent_total = GuideRecord::where($where)->sum('real_total');
return $rent_total;
}
public function guideFinish($spot_id)
{
$where = [
['is_pay', '=', 1],
['spot_id', '=', $spot_id],
];
$number = GuideRecord::where($where)->count();
return $number;
}
}