User.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 getUserById($uid)
  14. {
  15. return Db::table(self::$table)->where(['id' => $uid])->find();
  16. }
  17. public static function getUserByMobile($mobile)
  18. {
  19. return Db::table(self::$table)->where('mobile', $mobile)->find();
  20. }
  21. public static function ModifyMobile($uid, $phone)
  22. {
  23. return Db::table(self::$table)
  24. ->where(['id' => $uid])
  25. ->update([
  26. 'mobile' => $phone,
  27. 'update_time' => date('Y-m-d H:i:s')
  28. ]);
  29. }
  30. public static function modifyUserPidAndPath($uid, $pid, $newPathPrefix)
  31. {
  32. return Db::table(self::$table)
  33. ->where(['id' => $uid])
  34. ->update([
  35. 'pid' => $pid,
  36. 'path' => $newPathPrefix,
  37. 'update_time' => date('Y-m-d H:i:s')
  38. ]);
  39. }
  40. public static function modifyUserPath($id, $newPath)
  41. {
  42. return Db::table(self::$table)
  43. ->where(['id' => $id])
  44. ->update([
  45. 'path' => $newPath,
  46. 'update_time' => date('Y-m-d H:i:s')
  47. ]);
  48. }
  49. public static function UpdateUserMoney($id, $money)
  50. {
  51. return Db::table(self::$table)
  52. ->where(['id' => $id])
  53. ->update([
  54. 'money' => $money,
  55. 'update_time' => date('Y-m-d H:i:s')
  56. ]);
  57. }
  58. public static function UpdateUserScore($id, $score)
  59. {
  60. return Db::table(self::$table)
  61. ->where(['id' => $id])
  62. ->update([
  63. 'score' => $score,
  64. 'update_time' => date('Y-m-d H:i:s')
  65. ]);
  66. }
  67. public static function updateState($id, int $status)
  68. {
  69. return Db::table(self::$table)
  70. ->where(['id' => $id])
  71. ->update([
  72. 'status' => $status,
  73. 'update_time' => date('Y-m-d H:i:s')
  74. ]);
  75. }
  76. public function getCount($where, $userMap)
  77. {
  78. return $this->model
  79. ->withJoin('userData', 'INNER')
  80. ->where($where)
  81. ->where($userMap)
  82. ->count();
  83. }
  84. public function getPageList($page, $limit, $where, $sort, $userMap)
  85. {
  86. return $this->model
  87. ->withJoin('userData', 'INNER')
  88. ->where($where)
  89. ->where($userMap)
  90. ->page($page, $limit)
  91. ->order($sort)
  92. ->select();
  93. }
  94. }