OwnerSundryFeeDetailService.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace App\Services;
  3. use App\Traits\ServiceAppAop;
  4. use App\OwnerSundryFeeDetail;
  5. use Illuminate\Contracts\Pagination\LengthAwarePaginator;
  6. use Illuminate\Database\Eloquent\Builder;
  7. class OwnerSundryFeeDetailService implements \App\Interfaces\SettlementBillReportInterface
  8. {
  9. use ServiceAppAop;
  10. use \App\Traits\SettlementBillServiceTrait;
  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. list($start, $end) = $this->getStartAndEnd($counting_month);
  22. return OwnerSundryFeeDetail::query()
  23. ->with(['owner', 'logistic'])
  24. ->where('owner_id', $owner_id)
  25. ->whereBetween('created_at', [$start, $end]);
  26. }
  27. public function switchType($type)
  28. {
  29. // TODO: Implement switchType() method.
  30. }
  31. public function buildExport($details): array
  32. {
  33. // TODO: Implement buildExport() method.
  34. }
  35. public function add(array $model)
  36. {
  37. // TODO: Implement add() method.
  38. }
  39. public function getTotalFee($owner_id, $counting_month)
  40. {
  41. list($start, $end) = $this->getStartAndEnd($counting_month);
  42. return OwnerSundryFeeDetail::query()
  43. ->selectRaw("type,sum(fee) as fee")
  44. ->where('owner_id', $owner_id)
  45. ->whereBetween('created_at', [$start, $end])
  46. ->groupBy('type')
  47. ->get();
  48. }
  49. public function recordReport($counting_month = null,array $ownerIds = [])
  50. {
  51. // TODO: Implement recordReport() method.
  52. }
  53. }