1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- /**
- *
- *
- * @category xxx
- * @package PSR
- * @subpackage Documentation\API
- * @author xxx <xxx@xxx.com>
- * @license GPL https://xxx.com
- * @link https://xxx.com
- * @ctime: 2020/4/30 15:41
- */
- namespace App\Repositories;
- use App\Models\DepositCard;
- use App\Models\User;
- class DepositCardRepository extends BaseRepository
- {
- public function __construct(DepositCard $depositCard)
- {
- $this->model = $depositCard;
- }
- /**
- * 判断骑行卡是否启用
- *
- * @param $id integer
- *
- * @return bool true表示可用 false不可用
- *
- * */
- public function isStatusOK($id)
- {
- $depositCard = $this->model->where('id', $id)->where('status', DepositCard::STATUS_OK)->first();
- if (empty($cardRiding)) return false;
- return true;
- }
- public function getDepositCardsByAreaId($area_id)
- {
- $depositCards = $this->model->where('area_id', $area_id)->where('status', DepositCard::STATUS_OK)->orderBy('effective_days')->get();
- return $depositCards;
- }
- /**
- * 判断能否购买免押金卡
- *
- * @param $user_id
- * @return bool
- * @author Fx
- *
- */
- public function isCanBuy($user_id)
- {
- $user = User::find($user_id);
- if ($user->deposit_type == User::DEPOSIT_MONEY && $user->is_deposit == User::DEPOSIT_OK) {
- // 押金类型为缴纳钱 并且已经缴纳过了
- return false;
- }
- return true;
- }
- }
|