| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace App\Services;
- use App\OwnerAreaReport;
- use App\OwnerBillReport;
- use App\Traits\ServiceAppAop;
- use App\OwnerBillReportArchive;
- use Illuminate\Database\Eloquent\Builder;
- use Illuminate\Database\Eloquent\Model;
- class OwnerBillReportArchiveService
- {
- use ServiceAppAop;
- protected $modelClass = OwnerBillReportArchive::class;
- /**
- * @param $counting_month
- * @param $owner_id
- * @param $type
- * @return Builder
- */
- public function getSql($counting_month, $owner_id, $type): Builder
- {
- return OwnerBillReportArchive::query()->where('counting_month', $counting_month)
- ->where('owner_id', $owner_id)->where('type', $type);
- }
- /**
- * @param $counting_month
- * @param $owner_id
- * @param $type
- * @return int
- */
- public function isArchived($counting_month, $owner_id, $type): int
- {
- $type = $this->switchType($type);
- return $this->getSql($counting_month, $owner_id, $type)->exists() ? 1 : 2;
- }
- /**
- * 获取确认账单数据
- * @param array $kvPairs
- * @return Builder|Model|object|null
- */
- public function get(array $kvPairs)
- {
- return $this->getSql($kvPairs['counting_month'], $kvPairs['owner_id'], $this->switchType($kvPairs['type']))->first();
- }
- /**
- * @param $type
- * @return int|mixed
- */
- private function switchType($type)
- {
- //枚举转换
- if (is_string($type)) {
- $type = OwnerBillReportArchive::$enums['type'][$type];
- }
- return $type;
- }
- }
|