UserBindPhoneService.php 1020 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: z-yang
  5. * Date: 2019/7/4
  6. * Time: 16:52
  7. */
  8. namespace App\Modules\User\Services;
  9. use App\Modules\User\Models\UserBindPhone;
  10. class UserBindPhoneService
  11. {
  12. public static function bindInfo($uid)
  13. {
  14. $model = new UserBindPhone();
  15. return $model->join('users','users.openid','=','user_bind_phone.openid')
  16. ->select('user_bind_phone.uid','user_bind_phone.phone')
  17. ->where('users.id',$uid)
  18. ->first();
  19. }
  20. public static function bind($uid,$openid,$phone,$from){
  21. $model = new UserBindPhone();
  22. $info = $model->where('phone',$phone)->select('id')->first();
  23. if($info){
  24. return -1;
  25. }
  26. $info2 = $model->where('openid',$openid)->select('id')->first();
  27. if($info2){
  28. return -2;
  29. }
  30. $model->uid = $uid;
  31. $model->openid = $openid;
  32. $model->phone = $phone;
  33. $model->from = $from;
  34. $model->save();
  35. return 0;
  36. }
  37. }