OwnerSundryFeeDetailService.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace App\Services;
  3. use App\Traits\ServiceAppAop;
  4. use App\OwnerSundryFeeDetail;
  5. use Carbon\Carbon;
  6. use Illuminate\Contracts\Pagination\LengthAwarePaginator;
  7. use Illuminate\Database\Eloquent\Builder;
  8. class OwnerSundryFeeDetailService implements \App\Interfaces\SettlementBillDetailInterface
  9. {
  10. use ServiceAppAop;
  11. protected $modelClass = OwnerSundryFeeDetail::class;
  12. /** @var OwnerBillReportArchiveService $archiveService */
  13. private $archiveService;
  14. const TYPE = '杂项费';
  15. public function get(array $kvPairs): LengthAwarePaginator
  16. {
  17. return $this->getSql($kvPairs['owner_id'], $kvPairs['counting_month'])->paginate($kvPairs['paginateParams']['paginate'] ?? 50);
  18. }
  19. public function getSql($owner_id, $counting_month): Builder
  20. {
  21. $start = Carbon::parse($counting_month)->startOfMonth()->startOfDay()->toDateTimeString();
  22. $end = Carbon::parse($counting_month)->endOfMonth()->endOfDay()->toDateTimeString();
  23. return OwnerSundryFeeDetail::query()
  24. ->with(['owner', 'logistic'])
  25. ->where('owner_id', $owner_id)
  26. ->whereBetween('created_at', [$start, $end]);
  27. }
  28. public function switchType($type)
  29. {
  30. // TODO: Implement switchType() method.
  31. }
  32. public function buildExport($details): array
  33. {
  34. // TODO: Implement buildExport() method.
  35. }
  36. public function add(array $model)
  37. {
  38. // TODO: Implement add() method.
  39. }
  40. }