fix gold_num

This commit is contained in:
lwl0608 2023-12-23 17:09:07 +08:00
parent 6efe1afbcd
commit 9f62b24fff
4 changed files with 55 additions and 14 deletions

View File

@ -4,19 +4,20 @@ import "service/dbstruct"
// 查询自己返回的实体
type ApiListVO struct {
Mid *int64 `json:"mid" bson:"_id"` // 用户表Id
Name *string `json:"name" bson:"name"` // 用户名
UserId *int64 `json:"user_id" bson:"user_id"` // 业务Id
Avatar *dbstruct.MediaComponent `json:"avatar" bson:"avatar"` // 头像
Level *int64 `json:"level" bson:"level"` // 等级
Role *int64 `json:"role" bson:"role"` // 角色
CurrentExp *int64 `json:"current_exp" bson:"current_exp"` // 当前经验
CurrentLevelExp *int64 `json:"current_level_exp" bson:"current_level_exp"` // 当前等级总经验
IsDndModeEnabled *int64 `json:"is_dnd_mode_enabled" bson:"is_dnd_mode_enabled"` // 是否开启勿扰模式
GoldNum *int64 `json:"gold_num" bson:"gold_num"` // 金币数量
DiamondNum *int64 `json:"diamond_num" bson:"diamond_num"` // 钻石数量
Ct *int64 `json:"ct" bson:"ct"` // 创建时间
Ut *int64 `json:"ut" bson:"ut"` // 更新时间
Mid *int64 `json:"mid" bson:"_id"` // 用户表Id
Name *string `json:"name" bson:"name"` // 用户名
UserId *int64 `json:"user_id" bson:"user_id"` // 业务Id
Avatar *dbstruct.MediaComponent `json:"avatar" bson:"avatar"` // 头像
Level *int64 `json:"level" bson:"level"` // 等级
Role *int64 `json:"role" bson:"role"` // 角色
CurrentExp *int64 `json:"current_exp" bson:"current_exp"` // 当前经验
CurrentLevelExp *int64 `json:"current_level_exp" bson:"current_level_exp"` // 当前等级总经验
IsDndModeEnabled *int64 `json:"is_dnd_mode_enabled" bson:"is_dnd_mode_enabled"` // 是否开启勿扰模式
GoldNum *int64 `json:"gold_num" bson:"gold_num"` // 金币数量
DiamondNum *int64 `json:"diamond_num" bson:"diamond_num"` // 钻石数量
WithdrawDiamondNum *int64 `json:"withdraw_diamond_num" bson:"withdraw_diamond_num"` // 提现钻石数量
Ct *int64 `json:"ct" bson:"ct"` // 创建时间
Ut *int64 `json:"ut" bson:"ut"` // 更新时间
}
// 查询别人返回的实体
@ -46,6 +47,13 @@ func (vo *ApiListVO) CopyAccount(account *dbstruct.Account) *ApiListVO {
return vo
}
func (vo *ApiListVO) CopyWallet(wallet *dbstruct.Wallet) *ApiListVO {
vo.GoldNum = wallet.Coins
vo.DiamondNum = wallet.Diamonds
vo.WithdrawDiamondNum = wallet.WithdrawDiamonds
return vo
}
func (vo *ApiListOthersVO) CopyAccount(account *dbstruct.Account) *ApiListOthersVO {
vo.Mid = account.Mid
vo.Name = account.Name

View File

@ -99,6 +99,9 @@ func (s *Service) ApiLoginByPswd(ctx *gin.Context, req *loginproto.ApiLoginByPsw
accountVO = &accountproto.ApiListVO{}
accountVO.CopyAccount(account)
wallet, _ := _DefaultVas.CheckWalletExist(ctx, util.DerefInt64(account.Mid))
accountVO.CopyWallet(wallet)
return
}
@ -171,6 +174,10 @@ func (s *Service) ApiLoginByVeriCode(ctx *gin.Context, req *loginproto.ApiLoginB
isEnabled = util.DerefInt64(login.IsEnabled)
accountVO = &accountproto.ApiListVO{}
accountVO.CopyAccount(account)
wallet, _ := _DefaultVas.CheckWalletExist(ctx, util.DerefInt64(account.Mid))
accountVO.CopyWallet(wallet)
return
}
@ -371,6 +378,8 @@ func (s *Service) ApiGetAccountListByMid(ctx *gin.Context, req *accountproto.Api
vo = &accountproto.ApiListVO{}
vo.CopyAccount(account)
wallet, _ := _DefaultVas.CheckWalletExist(ctx, util.DerefInt64(req.Mid))
vo.CopyWallet(wallet)
return
}
@ -392,6 +401,9 @@ func (s *Service) ApiGetAccountListByMids(ctx *gin.Context, req *accountproto.Ap
for i, account := range list {
volist[i] = &accountproto.ApiListVO{}
volist[i].CopyAccount(account)
wallet, _ := _DefaultVas.CheckWalletExist(ctx, util.DerefInt64(account.Mid))
volist[i].CopyWallet(wallet)
}
return
}
@ -410,6 +422,9 @@ func (s *Service) ApiGetAccountListByUserId(ctx *gin.Context, req *accountproto.
vo = &accountproto.ApiListVO{}
vo.CopyAccount(account)
wallet, _ := _DefaultVas.CheckWalletExist(ctx, util.DerefInt64(account.Mid))
vo.CopyWallet(wallet)
return
}
@ -432,6 +447,9 @@ func (s *Service) ApiGetAccountListFuzzilyByUserId(ctx *gin.Context, req *accoun
for i, account := range list {
volist[i] = &accountproto.ApiListVO{}
volist[i].CopyAccount(account)
wallet, _ := _DefaultVas.CheckWalletExist(ctx, util.DerefInt64(account.Mid))
volist[i].CopyWallet(wallet)
}
return
}
@ -455,6 +473,9 @@ func (s *Service) ApiGetAccountListFuzzilyByName(ctx *gin.Context, req *accountp
for i, account := range list {
volist[i] = &accountproto.ApiListVO{}
volist[i].CopyAccount(account)
wallet, _ := _DefaultVas.CheckWalletExist(ctx, util.DerefInt64(account.Mid))
volist[i].CopyWallet(wallet)
}
return
}

View File

@ -828,6 +828,18 @@ func (v *Vas) OneStepUnlockContact(ctx *gin.Context, req *vasproto.OneStepUnlock
logger.Error("DecCoins fail, mid: %v, coinPrice: %v, err: %v", req.Mid, coinPrice, err)
return
}
// 给主播加钻石
//var (
// TotalDias = coinPrice
// StreamerDias = int64(float64(coinPrice) * 0.8)
// InviterDias = int64(0)
// OfficialDias = int64(0)
//)
//if {
//
//}
//v.store.IncDiamonds(ctx, tx, req.Uid)
return
}

View File

@ -39,7 +39,7 @@ CREATE TABLE `vas_wallet`
);
-- vas_ch_cost、vas_ch_charge、vas_ch_income、vas_ch_withdraw
CREATE TABLE `vas_ch_withdraw`
CREATE TABLE `vas_ch_income`
(
`id` bigint AUTO_INCREMENT COMMENT 'id',
`mid` bigint NOT NULL COMMENT '用户id',