首页
学习
活动
专区
圈层
工具
发布

【Golang 语言社区】 社区APP 红包模块设计思路及实现

社区的APP 还在紧张的开发中,现在剧透APP的部分功能模块; 今天剧透的是 APP的红包模块。 红包设计思路: 1 促进用户的使用,对于积极的用户我们社区是给予了很大的回馈措施,回馈的措施就是大力无限量的红包回馈用户。 2 红包功能,主要包括,注册用户送红包,看文章送红包,回答问答送红包; 3 红包的内容非RMB,主要是一些软性的东西,例如,G币或者G豆,社区论坛的金币;最最优惠的属于送论坛的VIP。 4 剧透重要的是思想,以下代码大家主要是理解思路;代码部分重要的被***替代。

// 红包的协议的处理的方式

func (this *OnlineUser) PlayerGetBriberyMoneyFun(ProtocolData map[string]interface{}) {

Log_Eio.Log("Entry PlayerGetBriberyMoneyFun")

Log_Eio.Fmt("Entry PlayerGetBriberyMoneyFun")

// 获取客户端传递的数据;获取是申请什么样子的红包

iRoleUID := ProtocolData["RoleUID"].(float64) // 用户基本的UID

iBriberyMoneyType := ProtocolData["BriberyMoneyType"].(float64) // 用户基本的操作

Log_Eio.Fmt(iBriberyMoneyType)

// 产生随机红包的道具的类型

GoDouNUMtmp, GoBiNUMtmp, CoinNUMtmp := this.CreateRandCoinOrGoDouOrGoBiNUMFun(int(iBriberyMoneyType))

// 需要传输的数据的结构

BriberyMoneyinfo := Proto2_Data.HS2C_GetBriberyMoney{

Protocol: Proto_Data.Go_Of_VIP_Proto, // 主协议

Protocol2: Proto2_Data.HS2C_GetBriberyMoney_Proto, // 子协议

IsSucc: true, // 购买成功

GoDouNUM: uint32(GoDouNUMtmp),

GoBiNUM: uint32(GoBiNUMtmp),

CoinNUM: uint32(CoinNUMtmp),

DuiHuanMa: *************, // 兑换码

StrMsg: "buy succ 你有个勋章需要领取",

}

// 发送给玩家数据

this.PlayerSendMessage(BriberyMoneyinfo)

// 更新数据库及内存数据库

dbif.*********************

return

}

下一篇
举报
领券