12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Mead
- * Date: 2019/8/6
- * Time: 9:16 PM
- */
- namespace App\Repositories;
- use App\Models\InviteNewUsersGiveGiftLog;
- use App\Models\User;
- use App\Models\WalletLog;
- use Carbon\Carbon;
- class UserRepository extends BaseRepository
- {
- public function __construct(User $user)
- {
- $this->model = $user;
- }
- public function getRandomUserInfo()
- {
- return [
- ];
- }
- /**
- * 获取用户状态
- * @param $user_id
- * @return mixed
- * User: Mead
- */
- public function byIdGetUserStatus($user_id)
- {
- return $this->model->where('id', $user_id)->first();
- }
- /**
- * 是否正常
- * @param $user_id
- * @return mixed
- * Author: Mead
- */
- public function byIdCheckStatusOk($user_id)
- {
- return $this->model->where('id', $user_id)->value('status');
- }
- public function inviteNewRewardBalance($money, $user_id, $logs_id)
- {
- // 钱包记录
- WalletLog::log(WalletLog::OPERATE_TYPE_ADD, $money, $user_id,
- WalletLog::TYPE_ADD_INVITE_NEW_TO_WELLET, $this->model->register_area_id, $logs_id, InviteNewUsersGiveGiftLog::class);
- // 增加余额
- $wallet_money = $this->model->wallet_money;
- $wallet_money = bcadd($wallet_money, $money, 2);
- $this->model->update(['wallet_money' => $wallet_money]);
- }
- /**
- * 判断免押金卡是否到期 并更新 isDepositCardExpired
- *
- * @param $user_id
- * @return bool false 已过期 | true 正常
- * @author Fx
- *
- */
- public function isDepositCardExpired($user_id)
- {
- $user = $this->model->find($user_id);
- $deposit_expire_time = Carbon::parse($user->deposit_expire_time);
- if (Carbon::now()->gt($deposit_expire_time)) {
- //判断第一个日期是否比第二个日期大
- $user->is_deposit = User::DEPOSIT_NO;
- $user->deposit_type = User::DEPOSIT_TYPE_NO;
- $user->save();
- return false;
- }
- return true;
- }
- }
|