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(); } public static function modifyUserPidAndPath($uid, $pid, $newPathPrefix) { return Db::table(self::$table) ->where(['id' => $uid]) ->update([ 'pid' => $pid, 'path' => $newPathPrefix, 'update_time' => sr_getcurtime(time()) ]); } public static function modifyUserPath($id, $newPath) { return Db::table(self::$table) ->where(['id' => $id]) ->update([ 'path' => $newPath, 'update_time' => sr_getcurtime(time()) ]); } public static function UpdateUserMoney($id, $money) { return Db::table(self::$table) ->where(['id' => $id]) ->update([ 'money' => $money, 'update_time' => sr_getcurtime(time()) ]); } public static function UpdateUserScore($id, $score) { return Db::table(self::$table) ->where(['id' => $id]) ->update([ 'score' => $score, 'update_time' => sr_getcurtime(time()) ]); } public static function updateStatus($id, int $status) { return Db::table(self::$table) ->where(['id' => $id]) ->update([ 'status' => $status, 'update_time' => sr_getcurtime(time()) ]); } public static function getUserOrEmptyById($id) { return (new UserModel())->findOrEmpty($id); } public static function update($id, $userData) { $userData['update_time'] = sr_getcurtime(time()); return Db::table(self::$table) ->where(['id' => $id]) ->update($userData); } public static function updateTotalTeamWithdraw($path, $apply_money) { Db::table(self::$table)->whereIn('id', $path)->inc('total_team_withdraw', $apply_money)->update(); } public function getUserDetail($id) { return $this->model ->withJoin('userData', 'INNER') ->where('id', $id) ->find() ->toArray(); } 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(); } }