RechargeConfigurationRepository.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. *
  4. *
  5. * @category xxx
  6. * @package PSR
  7. * @subpackage Documentation\API
  8. * @author xxx <xxx@xxx.com>
  9. * @license GPL https://xxx.com
  10. * @link https://xxx.com
  11. * @ctime: 2020/3/24 14:38
  12. */
  13. namespace App\Repositories;
  14. use App\Models\RechargeConfiguration;
  15. use Illuminate\Cache\Repository;
  16. use Illuminate\Contracts\Cache\Store;
  17. class RechargeConfigurationRepository extends BaseRepository
  18. {
  19. public function __construct(RechargeConfiguration $rechargeConfiguration)
  20. {
  21. $this->model = $rechargeConfiguration;
  22. }
  23. public function getAllByAreaId($area_id)
  24. {
  25. return $this->model->where('area_id', $area_id)->where('status', RechargeConfiguration::STATUS_OK)->get();
  26. }
  27. /**
  28. *
  29. * @param $area_id
  30. */
  31. public function byAreaIdGetActiveConfig($area_id)
  32. {
  33. $now = now();
  34. return $this->model->where('area_id', $area_id)->where('start_at', '<=', $now)->where('end_at', '>=', $now)->where('status', RechargeConfiguration::STATUS_OK)->orderBy('id', 'desc')->limit(6)->get();
  35. }
  36. public function byIdGetActiveModel($id)
  37. {
  38. $now = now();
  39. return $this->model->where('id', $id)->where('start_at', '<=', $now)->where('end_at', '>=', $now)->where('status', RechargeConfiguration::STATUS_OK)->orderBy('id', 'desc')->first();
  40. }
  41. public function byMoneyGetActiveModel($money,$area_id)
  42. {
  43. $now = now();
  44. return $this->model->where('recharge_money', $money)->where('start_at', '<=', $now)->where('end_at', '>=', $now)->where('status', RechargeConfiguration::STATUS_OK)->where('area_id',$area_id)->orderBy('id', 'desc')->first();
  45. }
  46. public function getOneById($id)
  47. {
  48. return $this->model->where('id', $id)->where('status', RechargeConfiguration::STATUS_OK)->first();
  49. }
  50. }