新增 医生账户详情
This commit is contained in:
parent
fc738c4d32
commit
873b3b1676
@ -29,6 +29,7 @@ type sysSetting struct {
|
||||
// 医生管理
|
||||
type userDoctorManage struct {
|
||||
UserDoctor // 医生列表
|
||||
DoctorAccount
|
||||
}
|
||||
|
||||
// Basic 基础数据
|
||||
|
||||
83
api/controller/doctorAccount.go
Normal file
83
api/controller/doctorAccount.go
Normal file
@ -0,0 +1,83 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"hospital-admin-api/api/dao"
|
||||
"hospital-admin-api/api/dto"
|
||||
"hospital-admin-api/api/requests"
|
||||
"hospital-admin-api/api/responses"
|
||||
"hospital-admin-api/api/service"
|
||||
"hospital-admin-api/global"
|
||||
"hospital-admin-api/utils"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type DoctorAccount struct{}
|
||||
|
||||
// GetDoctorAccountPage 获取医生账户列表-分页
|
||||
func (r *DoctorAccount) GetDoctorAccountPage(c *gin.Context) {
|
||||
doctorAccountRequest := requests.DoctorAccountRequest{}
|
||||
req := doctorAccountRequest.GetDoctorAccountPage
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 参数验证
|
||||
if err := global.Validate.Struct(req); err != nil {
|
||||
responses.FailWithMessage(utils.Translate(err), c)
|
||||
return
|
||||
}
|
||||
|
||||
if req.Page == 0 {
|
||||
req.Page = 1
|
||||
}
|
||||
|
||||
if req.PageSize == 0 {
|
||||
req.PageSize = 20
|
||||
}
|
||||
|
||||
doctorAccountDao := dao.DoctorAccountDao{}
|
||||
doctorAccount, total, err := doctorAccountDao.GetDoctorAccountPage(req, req.Page, req.PageSize)
|
||||
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 处理返回值
|
||||
res := dto.GetDoctorAccountListDto(doctorAccount)
|
||||
|
||||
result := make(map[string]interface{})
|
||||
result["page"] = req.Page
|
||||
result["page_size"] = req.PageSize
|
||||
result["total"] = total
|
||||
result["data"] = res
|
||||
responses.OkWithData(result, c)
|
||||
}
|
||||
|
||||
// GetDoctorAccount 医生账户详情
|
||||
func (r *DoctorAccount) GetDoctorAccount(c *gin.Context) {
|
||||
id := c.Param("doctor_id")
|
||||
if id == "" {
|
||||
responses.FailWithMessage("缺少参数", c)
|
||||
return
|
||||
}
|
||||
|
||||
// 将 id 转换为 int64 类型
|
||||
doctorId, err := strconv.ParseInt(id, 10, 64)
|
||||
if err != nil {
|
||||
responses.Fail(c)
|
||||
return
|
||||
}
|
||||
|
||||
// 业务处理
|
||||
doctorAccountService := service.DoctorAccountService{}
|
||||
res, err := doctorAccountService.GetDoctorAccount(doctorId)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
responses.OkWithData(res, c)
|
||||
}
|
||||
@ -72,7 +72,7 @@ func (r *DoctorWithdrawal) GetDoctorWithdrawal(c *gin.Context) {
|
||||
}
|
||||
|
||||
// 业务处理
|
||||
doctorWithdrawaService := service.DoctorWithdrawaService{}
|
||||
doctorWithdrawaService := service.DoctorWithdrawalService{}
|
||||
res, err := doctorWithdrawaService.GetDoctorWithdrawal(withdrawalId)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
@ -152,7 +152,7 @@ func (r *DoctorWithdrawal) PutDoctorWithdrawalIncome(c *gin.Context) {
|
||||
}
|
||||
|
||||
// 业务处理
|
||||
doctorWithdrawaService := service.DoctorWithdrawaService{}
|
||||
doctorWithdrawaService := service.DoctorWithdrawalService{}
|
||||
_, err = doctorWithdrawaService.PutDoctorWithdrawalIncome(req, withdrawalId)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
@ -194,7 +194,7 @@ func (r *DoctorWithdrawal) PutDoctorWithdrawalExamine(c *gin.Context) {
|
||||
adminUserId := c.GetInt64("UserId")
|
||||
|
||||
// 业务处理
|
||||
doctorWithdrawaService := service.DoctorWithdrawaService{}
|
||||
doctorWithdrawaService := service.DoctorWithdrawalService{}
|
||||
_, err = doctorWithdrawaService.PutDoctorWithdrawalExamine(req, withdrawalId, adminUserId)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
@ -223,7 +223,7 @@ func (r *DoctorWithdrawal) PutDoctorWithdrawalPayment(c *gin.Context) {
|
||||
adminUserId := c.GetInt64("UserId")
|
||||
|
||||
// 业务处理
|
||||
doctorWithdrawaService := service.DoctorWithdrawaService{}
|
||||
doctorWithdrawaService := service.DoctorWithdrawalService{}
|
||||
_, err = doctorWithdrawaService.PutDoctorWithdrawalPayment(withdrawalId, adminUserId)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
|
||||
@ -3,6 +3,7 @@ package dao
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/api/requests"
|
||||
"hospital-admin-api/global"
|
||||
)
|
||||
|
||||
@ -88,3 +89,58 @@ func (r *DoctorAccountDao) Inc(tx *gorm.DB, maps interface{}, numeral float64, f
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetDoctorAccountPage 获取医生列表-分页
|
||||
func (r *DoctorAccountDao) GetDoctorAccountPage(req requests.GetDoctorAccountPage, page, pageSize int) (m []*model.DoctorAccount, total int64, err error) {
|
||||
var totalRecords int64
|
||||
|
||||
// 构建查询条件
|
||||
query := global.Db.Model(&model.DoctorAccount{})
|
||||
|
||||
// 医生
|
||||
query = query.Preload("UserDoctor", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Omit("open_id", "union_id", "wx_session_key")
|
||||
})
|
||||
|
||||
// 用户
|
||||
query = query.Preload("UserDoctor.User", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Omit("user_password", "salt")
|
||||
})
|
||||
|
||||
// 手机号
|
||||
if req.Mobile != "" {
|
||||
// 医生
|
||||
doctorUserSubQuery := global.Db.Model(&model.User{}).
|
||||
Select("user_id").
|
||||
Where("mobile = ?", req.Mobile)
|
||||
|
||||
doctorSubQuery := global.Db.Model(&model.UserDoctor{}).
|
||||
Select("doctor_id").
|
||||
Where(gorm.Expr("user_id IN (?)", doctorUserSubQuery))
|
||||
|
||||
query = query.Where("doctor_id IN (?)", doctorSubQuery)
|
||||
}
|
||||
|
||||
// 用户名称
|
||||
if req.UserName != "" {
|
||||
subQuery := global.Db.Model(&model.User{}).
|
||||
Select("doctor_id").
|
||||
Where("user_name LIKE ?", "%"+req.UserName+"%")
|
||||
|
||||
query = query.Where(gorm.Expr("doctor_id IN (?)", subQuery))
|
||||
}
|
||||
|
||||
// 排序
|
||||
query = query.Order("created_at desc")
|
||||
|
||||
// 查询总数量
|
||||
if err := query.Count(&totalRecords).Error; err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
err = query.Scopes(model.Paginate(page, pageSize)).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
return m, totalRecords, nil
|
||||
}
|
||||
|
||||
87
api/dto/DoctorAccount.go
Normal file
87
api/dto/DoctorAccount.go
Normal file
@ -0,0 +1,87 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/utils"
|
||||
)
|
||||
|
||||
type DoctorAccountDto struct {
|
||||
AccountId string `json:"account_id"` // 账户id
|
||||
DoctorId string `json:"doctor_id"` // 医生id
|
||||
TotalAmount float64 `json:"total_amount"` // 总金额(已结束订单的总金额)
|
||||
BalanceAccount float64 `json:"balance_account"` // 账户余额
|
||||
AppliedWithdrawalAmount float64 `json:"applied_withdrawal_amount"` // 提现金额
|
||||
ActualWithdrawalAmount float64 `json:"actual_withdrawal_amount"` // 实际提现金额
|
||||
IncomeTax float64 `json:"income_tax"`
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
|
||||
DoctorName string `json:"doctor_name"` // 医生姓名
|
||||
DoctorMobileMask string `json:"doctor_mobile_mask"` // 医生手机号(掩码)
|
||||
}
|
||||
|
||||
func GetDoctorAccountDto(m *model.DoctorAccount) *DoctorAccountDto {
|
||||
return &DoctorAccountDto{
|
||||
AccountId: fmt.Sprintf("%d", m.AccountId),
|
||||
DoctorId: fmt.Sprintf("%d", m.DoctorId),
|
||||
TotalAmount: m.TotalAmount,
|
||||
BalanceAccount: m.BalanceAccount,
|
||||
AppliedWithdrawalAmount: m.AppliedWithdrawalAmount,
|
||||
ActualWithdrawalAmount: m.ActualWithdrawalAmount,
|
||||
IncomeTax: m.IncomeTax,
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func GetDoctorAccountListDto(m []*model.DoctorAccount) []DoctorAccountDto {
|
||||
// 处理返回值
|
||||
responses := make([]DoctorAccountDto, len(m))
|
||||
|
||||
if len(m) > 0 {
|
||||
for i, v := range m {
|
||||
response := DoctorAccountDto{
|
||||
AccountId: fmt.Sprintf("%d", v.AccountId),
|
||||
DoctorId: fmt.Sprintf("%d", v.DoctorId),
|
||||
TotalAmount: v.TotalAmount,
|
||||
BalanceAccount: v.BalanceAccount,
|
||||
AppliedWithdrawalAmount: v.AppliedWithdrawalAmount,
|
||||
ActualWithdrawalAmount: v.ActualWithdrawalAmount,
|
||||
IncomeTax: v.IncomeTax,
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
|
||||
// 加载医生名称
|
||||
if v.UserDoctor != nil {
|
||||
response.LoadDoctorName(v.UserDoctor)
|
||||
|
||||
// 加载医生手机号(掩码)
|
||||
if v.UserDoctor.User != nil {
|
||||
response.LoadDoctorMobileMask(v.UserDoctor.User)
|
||||
}
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
responses[i] = response
|
||||
}
|
||||
}
|
||||
|
||||
return responses
|
||||
}
|
||||
|
||||
// LoadDoctorName 加载医生名称
|
||||
func (r *DoctorAccountDto) LoadDoctorName(m *model.UserDoctor) *DoctorAccountDto {
|
||||
if m != nil {
|
||||
r.DoctorName = m.UserName
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// LoadDoctorMobileMask 加载医生手机号(掩码)
|
||||
func (r *DoctorAccountDto) LoadDoctorMobileMask(m *model.User) *DoctorAccountDto {
|
||||
if m != nil {
|
||||
r.DoctorMobileMask = utils.MaskPhoneStr(m.Mobile)
|
||||
}
|
||||
return r
|
||||
}
|
||||
@ -36,6 +36,8 @@ func GetDoctorBankCardDto(m *model.DoctorBankCard) *DoctorBankCardDto {
|
||||
City: m.City,
|
||||
CountyId: m.CountyId,
|
||||
County: m.County,
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,6 +58,8 @@ func GetDoctorBankCardListDto(m []*model.DoctorBankCard) []DoctorBankCardDto {
|
||||
City: v.City,
|
||||
CountyId: v.CountyId,
|
||||
County: v.County,
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
|
||||
// 加载银行名称
|
||||
|
||||
@ -8,13 +8,14 @@ import (
|
||||
|
||||
// DoctorAccount 医生账户总表-已结束订单
|
||||
type DoctorAccount struct {
|
||||
AccountId int64 `gorm:"column:account_id;type:bigint(19);primary_key;comment:账户id" json:"account_id"`
|
||||
DoctorId int64 `gorm:"column:doctor_id;type:bigint(19);comment:医生id" json:"doctor_id"`
|
||||
TotalAmount float64 `gorm:"column:total_amount;type:decimal(18,8) unsigned;comment:总金额(已结束订单的总金额)" json:"total_amount"`
|
||||
BalanceAccount float64 `gorm:"column:balance_account;type:decimal(18,8) unsigned;default:0.00000000;comment:账户余额" json:"balance_account"`
|
||||
AppliedWithdrawalAmount float64 `gorm:"column:applied_withdrawal_amount;type:decimal(18,8) unsigned;default:0.00000000;comment:提现金额" json:"applied_withdrawal_amount"`
|
||||
ActualWithdrawalAmount float64 `gorm:"column:actual_withdrawal_amount;type:decimal(18,8) unsigned;default:0.00000000;comment:实际提现金额" json:"actual_withdrawal_amount"`
|
||||
IncomeTax float64 `gorm:"column:income_tax;type:decimal(18,8) unsigned;default:0.00000000;comment:所得税金额" json:"income_tax"`
|
||||
AccountId int64 `gorm:"column:account_id;type:bigint(19);primary_key;comment:账户id" json:"account_id"`
|
||||
DoctorId int64 `gorm:"column:doctor_id;type:bigint(19);comment:医生id" json:"doctor_id"`
|
||||
TotalAmount float64 `gorm:"column:total_amount;type:decimal(18,8) unsigned;comment:总金额(已结束订单的总金额)" json:"total_amount"`
|
||||
BalanceAccount float64 `gorm:"column:balance_account;type:decimal(18,8) unsigned;default:0.00000000;comment:账户余额" json:"balance_account"`
|
||||
AppliedWithdrawalAmount float64 `gorm:"column:applied_withdrawal_amount;type:decimal(18,8) unsigned;default:0.00000000;comment:提现金额" json:"applied_withdrawal_amount"`
|
||||
ActualWithdrawalAmount float64 `gorm:"column:actual_withdrawal_amount;type:decimal(18,8) unsigned;default:0.00000000;comment:实际提现金额" json:"actual_withdrawal_amount"`
|
||||
IncomeTax float64 `gorm:"column:income_tax;type:decimal(18,8) unsigned;default:0.00000000;comment:所得税金额" json:"income_tax"`
|
||||
UserDoctor *UserDoctor `gorm:"foreignKey:DoctorId;references:doctor_id" json:"user_doctor"` // 医生
|
||||
Model
|
||||
}
|
||||
|
||||
|
||||
13
api/requests/doctorAccount.go
Normal file
13
api/requests/doctorAccount.go
Normal file
@ -0,0 +1,13 @@
|
||||
package requests
|
||||
|
||||
type DoctorAccountRequest struct {
|
||||
GetDoctorAccountPage // 获取医生账户列表-分页
|
||||
}
|
||||
|
||||
// GetDoctorAccountPage 获取医生账户列表-分页
|
||||
type GetDoctorAccountPage struct {
|
||||
Page int `json:"page" form:"page" label:"页码"`
|
||||
PageSize int `json:"page_size" form:"page_size" label:"每页个数"`
|
||||
Mobile string `json:"mobile" form:"mobile" label:"手机号"`
|
||||
UserName string `json:"user_name" form:"user_name" label:"用户名"`
|
||||
}
|
||||
@ -369,6 +369,19 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
||||
// 获取医生银行卡列表-分页
|
||||
bankGroup.GET("", api.UserDoctor.GetUserDoctorBankCardPage)
|
||||
}
|
||||
|
||||
// 医生账户
|
||||
accountGroup := doctorGroup.Group("/account")
|
||||
{
|
||||
// 获取医生账户列表-分页
|
||||
accountGroup.GET("", api.DoctorAccount.GetDoctorAccountPage)
|
||||
|
||||
// 医生账户详情
|
||||
accountGroup.GET("/:doctor_id", api.DoctorAccount.GetDoctorAccount)
|
||||
|
||||
// 获取医生账户订单列表-分页
|
||||
accountGroup.GET("/order/:doctor_id", api.DoctorWithdrawal.GetDoctorWithdrawalOrderPage)
|
||||
}
|
||||
}
|
||||
|
||||
// 订单管理
|
||||
|
||||
45
api/service/DoctorAccount.go
Normal file
45
api/service/DoctorAccount.go
Normal file
@ -0,0 +1,45 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"hospital-admin-api/api/dao"
|
||||
"hospital-admin-api/api/dto"
|
||||
)
|
||||
|
||||
// DoctorAccountService 医生账户
|
||||
type DoctorAccountService struct {
|
||||
}
|
||||
|
||||
// GetDoctorAccount 提现详情
|
||||
func (r *DoctorAccountService) GetDoctorAccount(doctorId int64) (g *dto.DoctorAccountDto, err error) {
|
||||
doctorAccountDao := dao.DoctorAccountDao{}
|
||||
doctorAccount, err := doctorAccountDao.GetDoctorAccountByDoctorId(doctorId)
|
||||
if doctorAccount == nil {
|
||||
return nil, errors.New("数据错误")
|
||||
}
|
||||
|
||||
// 医生数据
|
||||
userDoctorDao := dao.UserDoctorDao{}
|
||||
userDoctor, err := userDoctorDao.GetUserDoctorById(doctorAccount.DoctorId)
|
||||
if err != nil {
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
|
||||
// 医生用户数据
|
||||
userDao := dao.UserDao{}
|
||||
user, err := userDao.GetUserById(userDoctor.UserId)
|
||||
if err != nil {
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
|
||||
// 处理返回值
|
||||
g = dto.GetDoctorAccountDto(doctorAccount)
|
||||
|
||||
// 加载医生名称
|
||||
g.LoadDoctorName(userDoctor)
|
||||
|
||||
// 加载医生手机号(掩码)
|
||||
g.LoadDoctorMobileMask(user)
|
||||
|
||||
return g, nil
|
||||
}
|
||||
@ -11,11 +11,11 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type DoctorWithdrawaService struct {
|
||||
type DoctorWithdrawalService struct {
|
||||
}
|
||||
|
||||
// GetDoctorWithdrawal 提现详情
|
||||
func (r *DoctorWithdrawaService) GetDoctorWithdrawal(withdrawalId int64) (g *dto.DoctorWithdrawalDto, err error) {
|
||||
func (r *DoctorWithdrawalService) GetDoctorWithdrawal(withdrawalId int64) (g *dto.DoctorWithdrawalDto, err error) {
|
||||
doctorWithdrawalDao := dao.DoctorWithdrawalDao{}
|
||||
doctorWithdrawal, err := doctorWithdrawalDao.GetDoctorWithdrawalById(withdrawalId)
|
||||
if doctorWithdrawal == nil {
|
||||
@ -75,7 +75,7 @@ func (r *DoctorWithdrawaService) GetDoctorWithdrawal(withdrawalId int64) (g *dto
|
||||
}
|
||||
|
||||
// PutDoctorWithdrawalIncome 修改提现个人所得税
|
||||
func (r *DoctorWithdrawaService) PutDoctorWithdrawalIncome(req requests.PutDoctorWithdrawalIncome, withdrawalId int64) (bool, error) {
|
||||
func (r *DoctorWithdrawalService) PutDoctorWithdrawalIncome(req requests.PutDoctorWithdrawalIncome, withdrawalId int64) (bool, error) {
|
||||
doctorWithdrawalDao := dao.DoctorWithdrawalDao{}
|
||||
doctorWithdrawal, _ := doctorWithdrawalDao.GetDoctorWithdrawalById(withdrawalId)
|
||||
if doctorWithdrawal == nil {
|
||||
@ -125,7 +125,7 @@ func (r *DoctorWithdrawaService) PutDoctorWithdrawalIncome(req requests.PutDocto
|
||||
}
|
||||
|
||||
// PutDoctorWithdrawalExamine 修改提现审核状态
|
||||
func (r *DoctorWithdrawaService) PutDoctorWithdrawalExamine(req requests.PutDoctorWithdrawalExamine, withdrawalId, adminUserId int64) (bool, error) {
|
||||
func (r *DoctorWithdrawalService) PutDoctorWithdrawalExamine(req requests.PutDoctorWithdrawalExamine, withdrawalId, adminUserId int64) (bool, error) {
|
||||
doctorWithdrawalDao := dao.DoctorWithdrawalDao{}
|
||||
doctorWithdrawal, _ := doctorWithdrawalDao.GetDoctorWithdrawalById(withdrawalId)
|
||||
if doctorWithdrawal == nil {
|
||||
@ -266,7 +266,7 @@ func (r *DoctorWithdrawaService) PutDoctorWithdrawalExamine(req requests.PutDoct
|
||||
}
|
||||
|
||||
// PutDoctorWithdrawalPayment 确认打款
|
||||
func (r *DoctorWithdrawaService) PutDoctorWithdrawalPayment(withdrawalId, adminUserId int64) (bool, error) {
|
||||
func (r *DoctorWithdrawalService) PutDoctorWithdrawalPayment(withdrawalId, adminUserId int64) (bool, error) {
|
||||
doctorWithdrawalDao := dao.DoctorWithdrawalDao{}
|
||||
doctorWithdrawal, _ := doctorWithdrawalDao.GetDoctorWithdrawalById(withdrawalId)
|
||||
if doctorWithdrawal == nil {
|
||||
@ -334,7 +334,7 @@ func (r *DoctorWithdrawaService) PutDoctorWithdrawalPayment(withdrawalId, adminU
|
||||
}
|
||||
|
||||
// 获取提现关联订单医生分成总金额
|
||||
func (r *DoctorWithdrawaService) getDoctorWithdrawalOrderAmountTotal(withdrawalId int64) (float64, error) {
|
||||
func (r *DoctorWithdrawalService) getDoctorWithdrawalOrderAmountTotal(withdrawalId int64) (float64, error) {
|
||||
// 获取医生提现-关联订单数据
|
||||
doctorWithdrawalOrderDao := dao.DoctorWithdrawalOrderDao{}
|
||||
doctorWithdrawalOrders, err := doctorWithdrawalOrderDao.GetDoctorWithdrawalOrderByWithdrawalId(withdrawalId)
|
||||
Loading…
x
Reference in New Issue
Block a user