User.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace app\admin\model\dao;
  3. use app\common\model\UserModel;
  4. use think\facade\Db;
  5. class User extends BaseDao
  6. {
  7. protected $model;
  8. public static $table = "db_user";
  9. public function __construct()
  10. {
  11. $this->model = new UserModel();
  12. }
  13. public static function getUids(array $uids)
  14. {
  15. return Db::table(self::$table)->whereIn('pid', $uids)->column('id');
  16. }
  17. public static function countScore(array $uids)
  18. {
  19. return Db::table(self::$table)->whereIn('id', $uids)->sum('score');
  20. }
  21. public static function countMoney(array $uids)
  22. {
  23. return Db::table(self::$table)->whereIn('id', $uids)->sum('money');
  24. }
  25. public static function getUserById($uid)
  26. {
  27. return Db::table(self::$table)->where('id', $uid)->find();
  28. }
  29. public static function getUserByMobile($mobile)
  30. {
  31. return Db::table(self::$table)->where('mobile', $mobile)->find();
  32. }
  33. public static function ModifyMobile($uid, $phone)
  34. {
  35. return Db::table(self::$table)
  36. ->where(['id' => $uid])
  37. ->update([
  38. 'mobile' => $phone,
  39. 'update_time' => date('Y-m-d H:i:s')
  40. ]);
  41. }
  42. public function getCount($where, $userMap)
  43. {
  44. return $this->model
  45. ->withJoin('userData', 'INNER')
  46. ->where($where)
  47. ->where($userMap)
  48. ->count();
  49. }
  50. public function getPageList($page, $limit, $where, $sort, $userMap)
  51. {
  52. return $this->model
  53. ->withJoin('userData', 'INNER')
  54. ->where($where)
  55. ->where($userMap)
  56. ->page($page, $limit)
  57. ->order($sort)
  58. ->select();
  59. }
  60. }