You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.2 KiB
Go

package user
import (
"dcg/app/user_center/usercenter"
"dcg/game/manager"
pbCommon "dcg/game/pb/common"
"dcg/game/svc"
"dcg/pkg/grpcx"
"git.noahlan.cn/northlan/ngs/component"
"git.noahlan.cn/northlan/ngs/session"
)
type UserCoinLogic struct {
component.Base
svcCtx *svc.ServiceContext
}
func NewUserCoin(svcCtx *svc.ServiceContext) *UserCoinLogic {
return &UserCoinLogic{
svcCtx: svcCtx,
}
}
func (p *UserCoinLogic) Init() {
}
func (p *UserCoinLogic) Shutdown() {
}
func (p *UserCoinLogic) CMD() string {
return "user"
}
func (p *UserCoinLogic) Prefix() string {
return "coin"
}
// Change 更新弹币
func (p *UserCoinLogic) Change(s *session.Session, msg *pbCommon.ChangeUserCoinReq) error {
_, err := p.svcCtx.UserCenterRpc.ChangeCoin(p.svcCtx.Ctx, &usercenter.ChangeCoinReq{
UserId: msg.UserId,
BattleId: manager.GameManager.BattleIdBySession(s),
Change: msg.Change,
Reason: msg.Reason,
})
if err != nil {
code, m, _ := grpcx.WrapGrpcErr(err)
return s.Response(&pbCommon.ChangeUserCoinResp{
Code: code,
Msg: m,
UserId: msg.UserId,
})
}
return s.Response(&pbCommon.ChangeUserCoinResp{
Code: 200,
Msg: "成功",
UserId: msg.UserId,
Change: msg.Change,
})
}