| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526 |
- package model
- import (
- "encoding/json"
- "rocommon/util"
- model2 "roserver/baseserver/model"
- "roserver/serverproto"
- "strconv"
- )
- //网易P1日志
- const (
- SDKPlatform_Quick = "SDKQuick"
- SDKPlatform_NBSDK = "SDKNB"
- SDKPlatform_UniSDK = "SDKUni" //SDKUni
- )
- func neteaseWriteLog(prefix string, logInfo interface{}) {
- return
- retStr, err := json.Marshal(logInfo)
- if err == nil {
- timeStr := util.GetCurrentTimeNow().Format("2006-01-02 15:04:05 Z0700")
- util.SpecialF("[%v][%v],%v", timeStr, prefix, string(retStr))
- }
- }
- //OnlineRoleNum
- type NeteaseLogOnlineRoleNum struct {
- Server int `json:"server"`
- Online int `json:"online"`
- OnLineTime uint64 `json:"on_line_time"`
- }
- func (this *NeteaseLogOnlineRoleNum) Log(role *Role) {
- neteaseWriteLog("OnlineRoleNum", this)
- }
- //LogoutRole
- type NeteaseLogCommonInfo struct {
- IPv4 string `json:"ip"`
- Server int `json:"server"`
- Ipv6 string `json:"ipv6"`
- DeviceModel string `json:"device_model"`
- DeviceHeight int `json:"device_height"`
- DeviceWidth int `json:"device_width"`
- OsName string `json:"os_name"`
- OsVer string `json:"os_ver"`
- MacAddr string `json:"mac_addr"`
- Udid string `json:"udid"`
- Isp string `json:"isp"`
- Network string `json:"network"`
- AppChannel string `json:"app_channel"`
- AppVer string `json:"app_ver"`
- TransId string `json:"transid"`
- UnisdkDeviceId string `json:"unisdk_deviceid"`
- IsEmulator int `json:"is_emulator"`
- IsRoot int `json:"is_root"`
- AccountId string `json:"account_id"`
- OldAccountId string `json:"old_accountid"`
- IMEI string `json:"imei"`
- CountryCode string `json:"country_code"`
- EnterSN string `json:"enter_sn"`
- OAid string `json:"oaid"`
- EngineVer string `json:"engine_ver"`
- }
- type NeteaseLogCreateRole struct {
- NeteaseLogCommonInfo
- Aid uint64 `json:"aid"`
- RoleId string `json:"role_id"` //角色唯一标识,在所有服唯一
- CreateTime uint64 `json:"create_time"` //s timestamp
- RoleName string `json:"role_name"`
- RoleLevel int `json:"role_level"`
- VipLevel int `json:"vip_level"`
- Exp int64 `json:"exp"`
- LogoutTime uint64 `json:"logout_time"` //s timestamp
- OnlineTime int `json:"online_time"` //s
- }
- type ItemData struct {
- ItemId int `json:"item_id"` //s
- ItemNum int `json:"item_num"` //s
- }
- type PayDetail struct {
- Name string `json:"prepaid_name"` //s
- GoodsId int `json:"prepaid_id"` //s
- GoodsType int `json:"prepaid_type"` //s
- }
- //充值日志
- type NeteaseLogRoleCharge struct {
- NeteaseLogCommonInfo
- //重置获得的道具
- RoleId string `json:"role_id"` //角色唯一标识,在所有服唯一
- RoleName string `json:"role_name"`
- RoleLevel int `json:"role_level"`
- VipLevel int `json:"vip_level"`
- PayChannel string `json:"pay_channel"`
- Gold int `json:"yuanbao"`
- FreeGold int `json:"free_yuanbao"`
- ChargeRMB float32 `json:"cash"`
- Currency string `json:"currency"`
- CurGold int `json:"left_yuanbao"`
- CurFreeGold int `json:"left_free_yuanbao"`
- PayTime uint64 `json:"pay_time"`
- PayMethod string `json:"pay_method"`
- ItemList []*ItemData `json:"get_item"` //s
- SN string `json:"sn"` //sSN string `json:"sn"` //s
- Consumesn string `json:"consumesn"`
- Detail PayDetail `json:"prepaid_detail"`
- Aid uint64 `json:"aid"`
- }
- //金币购买道具日志
- type NeteaseLogGoldBuyItem struct {
- NeteaseLogCommonInfo
- RoleId string `json:"role_id"` //角色唯一标识,在所有服唯一
- RoleName string `json:"role_name"`
- RoleLevel int `json:"role_level"`
- VipLevel int `json:"vip_level"`
- ItemId int `json:"item_id"` //获得的物品ID。
- ItemName string `json:"item_name"`
- BuyTime uint64 `json:"buy_time"`
- ExpireTime uint64 `json:"expire_time"`
- ItemCount int `json:"count"`
- Price int `json:"price"`
- Gold int `json:"yuanbao"` //购买花费的金币
- CurGold int `json:"left_yuanbao"` //当前的金币
- FreeGold int `json:"free_yuanbao"`
- CurFreeGold int `json:"left_free_yuanbao"`
- CostMoney int `json:"cost_money"`
- Aid uint64 `json:"aid"`
- }
- //金币购买其他物品
- type NeteaseLogGoldBuyOther struct {
- NeteaseLogCommonInfo
- RoleId string `json:"role_id"` //角色唯一标识,在所有服唯一
- RoleLevel int `json:"role_level"`
- VipLevel int `json:"vip_level"`
- Reason string `json:"reason"`
- Gold int `json:"yuanbao"` //购买花费的金币
- CurGold int `json:"left_yuanbao"` //当前的金币
- FreeGold int `json:"free_yuanbao"`
- CurFreeGold int `json:"left_free_yuanbao"`
- UseTime uint64 `json:"use_time"`
- Aid uint64 `json:"aid"`
- }
- //获得元宝日志
- type NeteaseLogRoleGetGold struct {
- NeteaseLogCommonInfo
- RoleId string `json:"role_id"` //角色唯一标识,在所有服唯一
- RoleName string `json:"role_name"`
- RoleLevel int `json:"role_level"`
- VipLevel int `json:"vip_level"`
- Reason string `json:"reason"`
- Gold int `json:"yuanbao"` //购买获得的金币
- FreeGold int `json:"free_yuanbao"`
- CurGold int `json:"left_yuanbao"` //当前的金币
- CurFreeGold int `json:"left_free_yuanbao"`
- GainTime uint64 `json:"gain_time"`
- Aid uint64 `json:"aid"`
- }
- //获得元宝日志 计费监控
- type NeteaseLogRoleGetGoldJF struct {
- NeteaseLogCommonInfo
- Aid uint64 `json:"aid"`
- RoleId string `json:"role_id"` //角色唯一标识,在所有服唯一
- RoleName string `json:"role_name"`
- RoleLevel int `json:"role_level"`
- VipLevel int `json:"vip_level"`
- GainType int `json:"gain_type"`
- SN string `json:"sn"`
- Consumesn string `json:"consumesn"`
- PayChannel string `json:"pay_channel"`
- Reason PayDetail `json:"reason"`
- TotalGold int `json:"yuanbao"` //购买需要的金币
- CurTotalGold int `json:"left_yuanbao"` //当前的金币
- PayGold int `json:"pay_yuanbao"` //当前的金币
- CurPayGold int `json:"left_pay_yuanbao"` //当前的金币
- FreeGold int `json:"free_yuanbao"`
- CurFreeGold int `json:"left_free_yuanbao"`
- GainTime uint64 `json:"gain_time"`
- }
- type UseReason struct {
- ItemId int `json:"item_id"`
- ItemName string `json:"item_name"`
- Count int `json:"count"`
- Info int `json:"info"`
- }
- //使用元宝日志 计费监控
- type NeteaseLogRoleUseGoldJF struct {
- NeteaseLogCommonInfo
- Aid uint64 `json:"aid"`
- RoleId string `json:"role_id"` //角色唯一标识,在所有服唯一
- RoleName string `json:"role_name"`
- RoleLevel int `json:"role_level"`
- VipLevel int `json:"vip_level"`
- UseType int `json:"use_type"`
- Reason UseReason `json:"reason"`
- TotalGold int `json:"yuanbao"` //消耗金币总量
- CurTotalGold int `json:"left_yuanbao"` //当前的金币总量
- PayGold int `json:"pay_yuanbao"` //消耗付费金币
- CurPayGold int `json:"left_pay_yuanbao"` //付费金币总量
- FreeGold int `json:"free_yuanbao"`
- CurFreeGold int `json:"left_free_yuanbao"`
- UseTime uint64 `json:"use_time"`
- }
- //聊天监控
- type NeteaseLogRoleChat struct {
- NeteaseLogCommonInfo
- RoleId string `json:"role_id"` //角色唯一标识,在所有服唯一
- RoleName string `json:"role_name"`
- RoleLevel int `json:"role_level"`
- Content string `json:"content"`
- Channel string `json:"channel"`
- Scene string `json:"scene"`
- Axis string `json:"axis"`
- ChatTime uint64 `json:"chat_time"`
- YAccount string `json:"y_account_id"`
- YRoleId string `json:"y_obj"`
- YLevel int `json:"y_level"`
- YName string `json:"y_name"`
- }
- func (this *NeteaseLogCreateRole) Log(role *Role) {
- if role == nil || role.GetPlatform() != SDKPlatform_UniSDK {
- return
- }
- if role.GetClientParam() != nil {
- this.NeteaseLogCommonInfo = *(role.GetClientParam())
- //this.commonInfo = *(role.GetClientParam())
- }
- this.Aid, _ = model2.Str2NumU64(role.GetOpenId())
- this.RoleId = strconv.FormatUint(role.GetUUid(), 10)
- this.CreateTime = role.RegisterTime / 1000 //s
- this.RoleName = role.GetNickName()
- this.RoleLevel = int(role.GetRoleLevel())
- this.VipLevel = int(role.GetRoleVipLevel())
- this.Exp = int64(role.GetRoleBase().GetRoleBaseExp())
- this.LogoutTime = role.GetRoleBase().RoleData().LastLoginTime / 1000 //s
- neteaseWriteLog("LogoutRole", this)
- }
- func (this *NeteaseLogRoleCharge) LogRoleCharge(role *Role) {
- if role == nil || role.GetPlatform() != SDKPlatform_UniSDK {
- return
- }
- if role.GetClientParam() != nil {
- this.NeteaseLogCommonInfo = *(role.GetClientParam())
- }
- this.Aid, _ = model2.Str2NumU64(role.GetOpenId())
- this.RoleId = strconv.FormatUint(role.GetUUid(), 10)
- this.RoleName = role.GetNickName()
- this.RoleLevel = int(role.GetRoleLevel())
- this.VipLevel = int(role.GetRoleVipLevel())
- this.FreeGold = 0
- this.CurFreeGold = 0
- neteaseWriteLog("Prepaid", this)
- }
- func (this *NeteaseLogGoldBuyItem) LogRoleGoldBuyItem(role *Role) {
- if role == nil || role.GetPlatform() != SDKPlatform_UniSDK {
- return
- }
- if role.GetClientParam() != nil {
- this.NeteaseLogCommonInfo = *(role.GetClientParam())
- }
- this.Aid, _ = model2.Str2NumU64(role.GetOpenId())
- this.RoleId = strconv.FormatUint(role.GetUUid(), 10)
- this.RoleName = role.GetNickName()
- this.RoleLevel = int(role.GetRoleLevel())
- this.VipLevel = int(role.GetRoleVipLevel())
- this.FreeGold = 0
- this.CurFreeGold = 0
- this.CurGold = int(role.GetRmb())
- neteaseWriteLog("ItemBuy", this)
- }
- func (this *NeteaseLogGoldBuyOther) LogRoleGoldBuyOther(role *Role) {
- if role == nil || role.GetPlatform() != SDKPlatform_UniSDK {
- return
- }
- if role.GetClientParam() != nil {
- this.NeteaseLogCommonInfo = *(role.GetClientParam())
- }
- this.Aid, _ = model2.Str2NumU64(role.GetOpenId())
- this.RoleId = strconv.FormatUint(role.GetUUid(), 10)
- this.RoleLevel = int(role.GetRoleLevel())
- this.VipLevel = int(role.GetRoleVipLevel())
- this.FreeGold = 0
- this.CurFreeGold = 0
- this.CurGold = int(role.GetRmb())
- neteaseWriteLog("YuanbaoUse", this)
- }
- func (this *NeteaseLogRoleGetGold) LogRoleGetGold(role *Role) {
- if role == nil || role.GetPlatform() != SDKPlatform_UniSDK {
- return
- }
- if role.GetClientParam() != nil {
- this.NeteaseLogCommonInfo = *(role.GetClientParam())
- }
- this.Aid, _ = model2.Str2NumU64(role.GetOpenId())
- this.RoleId = strconv.FormatUint(role.GetUUid(), 10)
- this.RoleName = role.GetNickName()
- this.RoleLevel = int(role.GetRoleLevel())
- this.VipLevel = int(role.GetRoleVipLevel())
- this.FreeGold = 0
- this.CurFreeGold = 0
- this.CurGold = int(role.GetRmb())
- neteaseWriteLog("YuanbaoGain", this)
- }
- func (this *NeteaseLogRoleGetGoldJF) LogRoleGetGoldJF(role *Role) {
- if role == nil || role.GetPlatform() != SDKPlatform_UniSDK {
- return
- }
- if role.GetClientParam() != nil {
- this.NeteaseLogCommonInfo = *(role.GetClientParam())
- }
- this.Aid, _ = model2.Str2NumU64(role.GetOpenId())
- this.RoleId = strconv.FormatUint(role.GetUUid(), 10)
- this.RoleName = role.GetNickName()
- this.RoleLevel = int(role.GetRoleLevel())
- this.VipLevel = int(role.GetRoleVipLevel())
- this.FreeGold = 0
- this.CurFreeGold = 0
- neteaseWriteLog("JFYuanbaoGain", this)
- }
- func (this *NeteaseLogRoleUseGoldJF) LogRoleUseGoldJF(role *Role) {
- if role == nil || role.GetPlatform() != SDKPlatform_UniSDK {
- return
- }
- if role.GetClientParam() != nil {
- this.NeteaseLogCommonInfo = *(role.GetClientParam())
- }
- this.Aid, _ = model2.Str2NumU64(role.GetOpenId())
- this.RoleId = strconv.FormatUint(role.GetUUid(), 10)
- this.RoleName = role.GetNickName()
- this.RoleLevel = int(role.GetRoleLevel())
- this.VipLevel = int(role.GetRoleVipLevel())
- this.FreeGold = 0
- this.CurFreeGold = 0
- neteaseWriteLog("JFYuanbaoUse", this)
- }
- func (this *NeteaseLogRoleChat) LogRoleChat(role *Role, targetRole *Role) {
- if role == nil || role.GetPlatform() != SDKPlatform_UniSDK {
- return
- }
- if role.GetClientParam() != nil {
- this.NeteaseLogCommonInfo = *(role.GetClientParam())
- }
- this.RoleId = strconv.FormatUint(role.GetUUid(), 10)
- this.RoleName = role.GetNickName()
- this.RoleLevel = int(role.GetRoleLevel())
- if targetRole != nil {
- this.YRoleId = strconv.FormatUint(targetRole.GetUUid(), 10)
- this.YLevel = int(targetRole.GetRoleLevel())
- this.YName = targetRole.GetNickName()
- if targetRole.GetClientParam() != nil {
- this.YAccount = targetRole.GetClientParam().AccountId
- }
- }
- neteaseWriteLog("Chat", this)
- }
- //uni sdk log
- func (this *Role) WriteChargeLog(payRewardInfo *serverproto.PayOrderSaveInfo) int {
- if payRewardInfo == nil {
- return 0
- }
- nLog := &NeteaseLogRoleCharge{
- PayChannel: payRewardInfo.PayChannel,
- ChargeRMB: payRewardInfo.Amount,
- CurGold: int(this.GetRmb()),
- SN: strconv.FormatUint(payRewardInfo.CpOrderId, 10),
- Consumesn: payRewardInfo.SdkOrderId,
- Currency: payRewardInfo.PayCurrency,
- PayMethod: payRewardInfo.PayMethod,
- PayTime: payRewardInfo.PayTime,
- }
- nLog.Detail.GoodsId = int(payRewardInfo.GoodsId)
- nLog.Detail.Name = payRewardInfo.GoodsName
- nLog.Detail.GoodsType = int(payRewardInfo.GoodsType)
- for _, data := range payRewardInfo.RewardList {
- if data.Key == int32(serverproto.ResType_Res_Rmb) {
- nLog.Gold = int(data.Value)
- }
- nLog.ItemList = append(nLog.ItemList, &ItemData{
- ItemId: int(data.Key),
- ItemNum: int(data.Value),
- })
- }
- nLog.LogRoleCharge(this)
- return nLog.Gold
- }
- //计费:充值获取金币
- func (this *Role) WriteChargeAddGoldLogJF(payRewardInfo *serverproto.PayOrderSaveInfo, gold int32) {
- if payRewardInfo == nil {
- return
- }
- nLog := &NeteaseLogRoleGetGoldJF{
- SN: strconv.FormatUint(payRewardInfo.CpOrderId, 10),
- Consumesn: payRewardInfo.SdkOrderId,
- TotalGold: int(gold),
- CurTotalGold: int(this.GetRmb()),
- PayGold: int(gold),
- CurPayGold: int(this.GetRmb()),
- GainTime: uint64(util.GetTimeSeconds()),
- GainType: 0,
- PayChannel: payRewardInfo.PayChannel,
- }
- nLog.Reason.Name = payRewardInfo.GoodsName
- nLog.Reason.GoodsId = int(payRewardInfo.GoodsId)
- nLog.Reason.GoodsType = int(payRewardInfo.GoodsType)
- nLog.LogRoleGetGoldJF(this)
- }
- //计费:非充值获取金币
- func (this *Role) WriteAddGoldLogJF(gold int32, addFrom int32) {
- nLog := &NeteaseLogRoleGetGoldJF{
- TotalGold: int(gold),
- CurTotalGold: int(this.GetRmb()),
- PayGold: int(gold),
- CurPayGold: int(this.GetRmb()),
- GainTime: uint64(util.GetTimeSeconds()),
- GainType: 0,
- }
- nLog.Reason.Name = strconv.FormatUint(uint64(addFrom), 10)
- nLog.LogRoleGetGoldJF(this)
- }
- //非计费:获取金币
- func (this *Role) WriteAddGoldLog(gold int32, addFrom int32, reason int32) {
- //nLog := &NeteaseLogRoleGetGold{
- // Gold: int(gold),
- // GainTime: uint64(util.GetTimeSeconds()),
- //}
- //
- //cfg, ok := serverproto.UseGoldPointLoader[int32(addFrom)]
- //if ok {
- // nLog.Reason = cfg.Explain
- //} else {
- // nLog.Reason = strconv.FormatUint(uint64(addFrom), 10)
- //}
- //nLog.LogRoleGetGold(this)
- }
- //计费:消耗金币
- func (this *Role) WriteUseGoldLogJF(st AddItemST) {
- nLog := &NeteaseLogRoleUseGoldJF{
- UseTime: uint64(util.GetTimeSeconds()),
- }
- if st.AddFrom == AddFrom_Shop_Buy ||
- st.AddFrom == AddFrom_Shop_Arane ||
- st.AddFrom == AddFrom_Shop_Dark ||
- st.AddFrom == AddFrom_Shop_Guild ||
- st.AddFrom == AddFrom_Shop_Pet {
- nLog.UseType = 0
- nLog.Reason.ItemId = int(st.ReasonParam)
- nLog.Reason.Count = int(st.ReasonParam2)
- shopCfg, ok := serverproto.ShopCfgLoader[st.ReasonParam]
- if ok {
- nLog.Reason.ItemName = shopCfg.GoodsName
- }
- } else {
- nLog.UseType = 1
- nLog.Reason.Info = int(st.AddFrom)
- }
- nLog.TotalGold = int(st.ItemCount)
- nLog.CurTotalGold = int(this.GetRmb())
- nLog.PayGold = int(st.ItemCount)
- nLog.CurPayGold = int(this.GetRmb())
- nLog.LogRoleUseGoldJF(this)
- }
- func (this *Role) WriteUseGoldOtherLog(st AddItemST) {
- //nLog := &NeteaseLogGoldBuyOther{
- // UseTime: uint64(util.GetTimeSeconds()),
- //}
- //
- //cfg, ok := serverproto.UseGoldPointLoader[int32(st.AddFrom)]
- //if ok {
- // nLog.Reason = cfg.Explain
- //} else {
- // nLog.Reason = strconv.FormatUint(uint64(st.AddFrom), 10)
- //}
- //nLog.Gold = int(st.ItemCount)
- //nLog.LogRoleGoldBuyOther(this)
- }
|