McMappingFans.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * Author: 芸众商城 www.yunzshop.com
  5. * Date: 17/3/5
  6. * Time: 上午4:07
  7. */
  8. namespace app\common\models;
  9. use app\backend\models\BackendModel;
  10. /**
  11. * Class McMappingFans
  12. * @package app\common\models
  13. */
  14. class McMappingFans extends BackendModel
  15. {
  16. public $table = 'mc_mapping_fans';
  17. protected $primaryKey = 'uid';
  18. public $timestamps = false;
  19. // public function getOauthUserInfo()
  20. // {
  21. // return mc_oauth_userinfo();
  22. // }
  23. //
  24. // public function getMemberId($uniacid)
  25. // {
  26. // $user_info = $this->getOauthUserInfo();
  27. //
  28. // return self::unionid()
  29. // ->where('openid', $user_info['openid'])
  30. // ->first()
  31. // ->toArray();
  32. // }
  33. public static function getUId($uniacid, $openid)
  34. {
  35. return self::select('uid')
  36. ->where('uniacid', $uniacid)
  37. ->where('openid', $openid)
  38. ->first();
  39. }
  40. public static function getFansById($memberId)
  41. {
  42. return self::uniacid()
  43. ->where('uid', $memberId)
  44. ->where('openid', '<>', '')
  45. ->orderBy('fanid', 'desc')
  46. ->first();
  47. }
  48. public static function getAllFans()
  49. {
  50. return self::uniacid()
  51. ->where('uid', '>', 0)
  52. ->get();
  53. }
  54. }