UserMember.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace backend\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "crm_member".
  6. *
  7. * @property integer $id
  8. * @property integer $login
  9. * @property integer $member_id
  10. * @property string $name
  11. * @property integer is_commission_run
  12. * @property integer in_time
  13. */
  14. class UserMember extends \yii\db\ActiveRecord
  15. {
  16. /**
  17. * @inheritdoc
  18. */
  19. public static function tableName()
  20. {
  21. return 'crm_user_member';
  22. }
  23. /**
  24. * @return \yii\db\Connection the database connection used by this AR class.
  25. */
  26. public static function getDb()
  27. {
  28. return Yii::$app->get('dbXcrm');
  29. }
  30. /**
  31. * 直客数
  32. * @param int $member_id
  33. * @return int
  34. */
  35. public static function directlyUserCount($member_id)
  36. {
  37. return self::find()->where(['member_id' => $member_id])->count();
  38. }
  39. /**
  40. * @param int $login
  41. * @return null|static
  42. */
  43. public static function findByLogin($login)
  44. {
  45. return static::find()->where(['login' => $login])->limit(1)->one();
  46. }
  47. }