| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- <?php
- namespace app\admin\model\dao;
- use app\common\model\UserModel;
- use think\facade\Db;
- class User extends BaseDao
- {
- protected $model;
- public static $table = "db_user";
- public function __construct()
- {
- $this->model = new UserModel();
- }
- public static function getUserById($uid)
- {
- return Db::table(self::$table)->where(['id' => $uid])->find();
- }
- public static function getUserByMobile($mobile)
- {
- return Db::table(self::$table)->where('mobile', $mobile)->find();
- }
- /**
- * 修改手机号码的时候同时修改用户名
- * @param $uid
- * @param $phone
- * @return int
- * @throws \think\db\exception\DbException
- */
- public static function ModifyMobile($uid, $phone)
- {
- return Db::table(self::$table)
- ->where(['id' => $uid])
- ->update([
- 'mobile' => $phone,
- 'user_name' => $phone,
- 'update_time' => date('Y-m-d H:i:s')
- ]);
- }
- public static function modifyUserPidAndPath($uid, $pid, $newPathPrefix)
- {
- return Db::table(self::$table)
- ->where(['id' => $uid])
- ->update([
- 'pid' => $pid,
- 'path' => $newPathPrefix,
- 'update_time' => date('Y-m-d H:i:s')
- ]);
- }
- public static function modifyUserPath($id, $newPath)
- {
- return Db::table(self::$table)
- ->where(['id' => $id])
- ->update([
- 'path' => $newPath,
- 'update_time' => date('Y-m-d H:i:s')
- ]);
- }
- public static function UpdateUserMoney($id, $money)
- {
- return Db::table(self::$table)
- ->where(['id' => $id])
- ->update([
- 'money' => $money,
- 'update_time' => date('Y-m-d H:i:s')
- ]);
- }
- public static function UpdateUserScore($id, $score)
- {
- return Db::table(self::$table)
- ->where(['id' => $id])
- ->update([
- 'score' => $score,
- 'update_time' => date('Y-m-d H:i:s')
- ]);
- }
- public static function updateState($id, int $status)
- {
- return Db::table(self::$table)
- ->where(['id' => $id])
- ->update([
- 'status' => $status,
- 'update_time' => date('Y-m-d H:i:s')
- ]);
- }
- public function getCount($where, $userMap)
- {
- return $this->model
- ->withJoin('userData', 'INNER')
- ->where($where)
- ->where($userMap)
- ->count();
- }
- public function getPageList($page, $limit, $where, $sort, $userMap)
- {
- return $this->model
- ->withJoin('userData', 'INNER')
- ->where($where)
- ->where($userMap)
- ->page($page, $limit)
- ->order($sort)
- ->select();
- }
- }
|