From 9f62b24fffcd2ef489b0929d00401d9b6156435a Mon Sep 17 00:00:00 2001 From: lwl0608 Date: Sat, 23 Dec 2023 17:09:07 +0800 Subject: [PATCH] fix gold_num --- api/proto/account/proto/account_vo_api.go | 34 ++++++++++++++--------- app/mix/service/apiservice.go | 21 ++++++++++++++ app/mix/service/logic/vas.go | 12 ++++++++ dbstruct/vas.sql | 2 +- 4 files changed, 55 insertions(+), 14 deletions(-) diff --git a/api/proto/account/proto/account_vo_api.go b/api/proto/account/proto/account_vo_api.go index 6640f9f5..9b77740e 100644 --- a/api/proto/account/proto/account_vo_api.go +++ b/api/proto/account/proto/account_vo_api.go @@ -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 diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go index 27f2ff6d..7fce67e6 100644 --- a/app/mix/service/apiservice.go +++ b/app/mix/service/apiservice.go @@ -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 } diff --git a/app/mix/service/logic/vas.go b/app/mix/service/logic/vas.go index 8f259f0d..bfb2102a 100644 --- a/app/mix/service/logic/vas.go +++ b/app/mix/service/logic/vas.go @@ -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 } diff --git a/dbstruct/vas.sql b/dbstruct/vas.sql index f00ddb06..efcb6f67 100644 --- a/dbstruct/vas.sql +++ b/dbstruct/vas.sql @@ -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',