1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?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/15 14:26
- */
- namespace App\Repositories;
- use App\Models\InviteNewUsersGiveGiftLog;
- class InviteNewUsersGiveGiftLogRepository extends BaseRepository
- {
- public $cardRidingUserBagsRepository;
- public $couponUserBagsRepository;
- public $userRepository;
- public function __construct(InviteNewUsersGiveGiftLog $inviteNewUsersGiveGiftLog,CardRidingUserBagsRepository $cardRidingUserBagsRepository,CouponUserBagsRepository $couponUserBagsRepository,UserRepository $userRepository)
- {
- $this->model = $inviteNewUsersGiveGiftLog;
- $this->cardRidingUserBagsRepository = $cardRidingUserBagsRepository;
- $this->couponUserBagsRepository = $couponUserBagsRepository;
- $this->userRepository = $userRepository;
- }
- /**
- * 获取得过奖励的id getRewardsByUserId
- *
- * @param $user_id
- * @return \Illuminate\Support\Collection
- * @author Fx
- *
- */
- public function getRewardsByUserId($user_id){
- return $this->model->query()
- ->where('user_id',$user_id)
- ->pluck('invite_new_users_configs_id');
- }
- /**
- * 是否领取过礼物 checkExist
- *
- * @param $data
- * @return bool
- * @author Fx
- *
- */
- public function checkExist($data)
- {
- $is = $this->model->where($data)->first();
- if (empty($is)) {
- return false;
- } else {
- return true;
- }
- }
- public function logs($data){
- $logs = $this->model->query()->create($data);
- switch ($data['gift_type']){
- case $this->model::GIFT_TYPE_COUPON:
- $this->couponUserBagsRepository->inviteNewRewardCoupon($data['gift_id'],$data['user_id'],$data['gift_num']);
- break;
- case $this->model::GIFT_TYPE_CARD:
- $this->cardRidingUserBagsRepository->inviteNewRewardCard($data['gift_id'],$data['user_id']);
- break;
- case $this->model::GIFT_TYPE_BALANCE:
- $this->userRepository->inviteNewRewardBalance($data['gift_id'],$data['user_id'],$logs->id);
- break;
- default:
- return false;
- }
- return $logs;
- }
- }
|