DepositCardRepository.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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/4/30 15:41
  12. */
  13. namespace App\Repositories;
  14. use App\Models\DepositCard;
  15. use App\Models\User;
  16. class DepositCardRepository extends BaseRepository
  17. {
  18. public function __construct(DepositCard $depositCard)
  19. {
  20. $this->model = $depositCard;
  21. }
  22. /**
  23. * 判断骑行卡是否启用
  24. *
  25. * @param $id integer
  26. *
  27. * @return bool true表示可用 false不可用
  28. *
  29. * */
  30. public function isStatusOK($id)
  31. {
  32. $depositCard = $this->model->where('id', $id)->where('status', DepositCard::STATUS_OK)->first();
  33. if (empty($cardRiding)) return false;
  34. return true;
  35. }
  36. public function getDepositCardsByAreaId($area_id)
  37. {
  38. $depositCards = $this->model->where('area_id', $area_id)->where('status', DepositCard::STATUS_OK)->orderBy('effective_days')->get();
  39. return $depositCards;
  40. }
  41. /**
  42. * 判断能否购买免押金卡
  43. *
  44. * @param $user_id
  45. * @return bool
  46. * @author Fx
  47. *
  48. */
  49. public function isCanBuy($user_id)
  50. {
  51. $user = User::find($user_id);
  52. if ($user->deposit_type == User::DEPOSIT_MONEY && $user->is_deposit == User::DEPOSIT_OK) {
  53. // 押金类型为缴纳钱 并且已经缴纳过了
  54. return false;
  55. }
  56. return true;
  57. }
  58. }